私は過去 1 年間、Android テクノロジで働いています。現在、Android 4.0.3 でアプリケーションの着信コール自動応答を開発したいのですが、このバージョンでは解決策が得られないか、このための API (ITelephony.aidl) が見つかりません。私に提案してください。
6276 次
3 に答える
2
その作業コード。最初に、Phone 状態の Broadcast Receiver を使用して着信を確認します。
filter.addAction("android.intent.action.PHONE_STATE");
mContext.registerReceiver(myCallReceiver, filter);
そして onReceive(Context context, Intent intent) で answerPhoneHeadsethook() 関数を呼び出します。
private void answerPhoneHeadsethook(Context context) {
// Simulate a press of the headset button to pick up the call
Intent buttonDown = new Intent(Intent.ACTION_MEDIA_BUTTON);
buttonDown.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(
KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_HEADSETHOOK));
context.sendOrderedBroadcast(buttonDown,
"android.permission.CALL_PRIVILEGED");
// froyo and beyond trigger on buttonUp instead of buttonDown
Intent buttonUp = new Intent(Intent.ACTION_MEDIA_BUTTON);
buttonUp.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(
KeyEvent.ACTION_UP, KeyEvent.KEYCODE_HEADSETHOOK));
context.sendOrderedBroadcast(buttonUp,
"android.permission.CALL_PRIVILEGED");
}
于 2012-11-29T16:05:42.240 に答える
0
電話に応答または拒否するには、MODIFY_PHONE_STATE パーミッションが必要です。残念ながら 2.3 以降では、システム アプリでのみ使用できます。(詳細はこちら)
通話に応答するための回避策 (元はhereから):
Intent i = new Intent(Intent.ACTION_MEDIA_BUTTON);
KeyEvent event = new KeyEvent(KeyEvent.ACTION_DOWN,KeyEvent.KEYCODE_HEADSETHOOK);
i.putExtra(Intent.EXTRA_KEY_EVENT, event );
context.sendOrderedBroadcast(i, null);
于 2012-07-30T13:46:36.703 に答える