2012-02-13 63 views
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(操作系统:Android 2.3.3)......任何人都可以帮助我解决这个问题!我会欣赏任何想法!谢谢! )

+0

你有没有解决这个问题?我是在浪费我的时间吗? – user1163234 2012-03-08 18:06:11

+0

它不能在HTC Desire Z,OS 2.3.3上工作......我很好奇这些设备是否有解决方法... – 2012-04-23 13:34:45

回答