2

I am developing an android application that detects and picks up incoming call. I using the following line of code to pick up the call

Runtime.getRuntime().exec("input keyevent " + KeyEvent.KEYCODE_HEADSETHOOK);

This works fine on all the phones I tested, but on Xperia Z4 this only works when my application is in foreground.

Based on my application logs the application is not suspended while in background, everything else works accept for the adb command.

There might be some kind of added security measure on this particular handset. Does any one know a way around?

PS: I test the application on Xperia Z3 and it works fine.

EDIT 1: I checked the android system logs and found that it is a permission problem. I got the following logs:

05-18 12:41:56.557 E/AndroidRuntime(20059): *** FATAL EXCEPTION IN SYSTEM PROCESS: main 05-18 12:41:56.557 E/AndroidRuntime(20059): java.lang.SecurityException: Injecting to another application requires INJECT_EVENTS permission.

I added this permission in the manifest file but it still didnt work. Any help is highly appreciated.

Rajat Saini
  • 557
  • 7
  • 26

0 Answers0