以编程方式自动接听来电? [英] Auto answer the incoming call programmatically?
本文介绍了以编程方式自动接听来电?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有用于获取到Android手机的来电号码的代码.但是,当来电来自特定号码时,我想自动接听电话.
I have the code for getting the number of the incoming call to a android phone. But I want to automatically answer the call when the incoming call is from a particular number.
我在互联网上找到了以下代码:
I found this code on the internet:
public class ServiceReceiver extends BroadcastReceiver {
private static final String TAG = null;
@SuppressWarnings({"unchecked", "rawtypes"})
@Override
public void onReceive(Context context, Intent intent) {
Toast.makeText(context, "GOT SOMETHING", Toast.LENGTH_SHORT).show();
MyPhoneStateListener phoneListener = new MyPhoneStateListener();
TelephonyManager telephony = (TelephonyManager)
context.getSystemService(Context.TELEPHONY_SERVICE);
telephony.listen(phoneListener, PhoneStateListener.LISTEN_CALL_STATE);
Bundle bundle = intent.getExtras();
String phoneNr = bundle.getString("incoming_number");
Log.v(TAG, "phoneNr: " + phoneNr);
String numb = "+4348873541";
Class c = Class.forName(telephony.getClass().getName());
Method m = c.getDeclaredMethod("getITelephony");
m.setAccessible(true);
if (phoneNr.equals(numb)) {
ITelephony telephonyService = (ITelephony) m.invoke(telephony);
telephonyService = (ITelephony) m.invoke(telephony);
telephonyService.silenceRinger();
telephonyService.answerRingingCall();
}
}
}
您能告诉我如何从特定号码自动接听电话吗?
Can you please tell me how to auto answer the call from a particular number?
推荐答案
从这里
选中此来源
他们发送蓝牙按键"事件来接听电话!
They send a Bluetooth "keydown" event to answer the call!
这篇关于以编程方式自动接听来电?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文