0

I am trying to answer an incoming call using Intent as below :

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

can anyone please tell where am i going wrong ... please help .

user
  • 65
  • 1
  • 11

3 Answers3

1

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

user
  • 65
  • 1
  • 11
0

Check out Answer incoming call in Android

Check out the source Code

GrIsHu
  • 29,068
  • 10
  • 64
  • 102
0

Try this. Its working fine for me.

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");  
}
Jebasuthan
  • 5,538
  • 6
  • 35
  • 55