本文介绍了在安卓4.0.3来电自动应答的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Android技术工作的最后1年。目前,我想开发的Android 4.0.3应用程序来电自动应答,但在这个版本我没有得到任何解决方案或无法找到这个(ITelephony.aidl)任何API。请给我建议。
I am working in Android technology last 1 years. Currently I want develop an application incoming call auto answer in Android 4.0.3 but in this version I am not getting any solution or can't find any api for this (ITelephony.aidl). Please suggest me.
推荐答案
其工作code。
首先找出其呼入电话使用国家广播接收器。
Its working code.First find out that its incoming call using Phone state Broadcast Receiver.
filter.addAction("android.intent.action.PHONE_STATE");
mContext.registerReceiver(myCallReceiver, filter);
,然后在的onReceive(上下文的背景下,意图意图)调用answerPhoneHeadsethook()函数。
and then in onReceive(Context context, Intent intent) call answerPhoneHeadsethook() function.
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");
}
这篇关于在安卓4.0.3来电自动应答的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!