我制作了这样的代码以编程方式回答:
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 之外的所有类型的手机(操作系统:Android 2.3.3)...谁能帮我解决这个问题!我会感激任何想法!谢谢!)