0

我正在尝试使用 Intent 接听来电,如下所示:

device.shell("am start -n com.android.phone/.InCallScreen -a android.intent.action.ANSWER")        

谁能告诉我哪里出错了……请帮忙。

4

3 回答 3

1

device.press("KEYCODE_CALL","DOWN")

于 2013-12-24T10:45:43.620 回答
0

签出在 Android 中接听来电

查看源代码

于 2013-12-24T10:40:46.420 回答
0

尝试这个。它对我来说工作正常。

public static void answerCall(Context context) {

     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");  
}
于 2014-01-09T07:52:35.313 回答