使用模拟按键的方式实现电话的接听与挂断
废话不多说,直接上代码,代码如下:
public void acceptNewCall(String phoneNum){ /* try{ Intent intent = new Intent("android.intent.action.MEDIA_BUTTON"); KeyEvent keyEvent = new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_HEADSETHOOK); intent.putExtra("android.intent.extra.KEY_EVENT",keyEvent); //sendOrderedBroadcast(intent,"android.permission.CALL_PRIVILEGED"); UserHandle userHandle = Process.myUserHandle(); if (ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.CALL_PRIVILEGED) != PackageManager.PERMISSION_GRANTED) { Logger.d(Module.BRACKETSERVER, "MainActivity: requestPermissions ");