我有code获取来电的号码为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.
我在互联网上找到这个code:
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?
由于从here
勾选此source
他们送蓝牙的keydown事件接听电话!
They send a Bluetooth "keydown" event to answer the call!
上一篇:如何通过JavaScript或jQuery来专注于Android浏览器中输入字段字段、器中、专注于、JavaScript
下一篇:抛出:IllegalArgumentException:没有查看发现ID为片段时快速切换动作条的标签抛出、片段、动作、快速