【问题标题】:Programmatically answer the call以编程方式接听电话
【发布时间】:2012-02-13 11:30:45
【问题描述】:

我编写了这样的代码以编程方式回答:

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) ...谁能帮我解决这个问题!我会感激任何想法!谢谢! )

【问题讨论】:

  • 你解决过这个问题吗?我这样做是在浪费时间吗?
  • 它不适用于 HTC Desire Z、OS 2.3.3...我很好奇这些设备是否存在任何解决方法...

标签: android call telephony headset


【解决方案1】:

请查看此链接,它在实际接听之前模拟耳机插入。 http://androidbridge.blogspot.com/2011/05/how-to-answer-incoming-call-in-android.html

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多