0

私はプログラムで答えるためにそのようなコードを作りました:

try {
   telephonyService.answerRingingCall();            
}
catch (Exception exx) {
     answerPhoneHeadsethook();
}

private void answerPhoneHeadsethook() {
    // 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));
    activity.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));
    activity.sendOrderedBroadcast(buttonUp, "android.permission.CALL_PRIVILEGED");
} 

だから...私はインターフェースITelephony.aidlで答えようとします、そしてそれができない場合は、Hadsethookでそれを作ります...それはHtc Sensation(OS:Android 2.3.3)を除くほとんどすべてのタイプの携帯電話で動作します...誰かが私がこの問題を解決するのを手伝ってくれる?どんなアイデアでもありがたいです!ありがとうございました!)。

4

1 に答える 1