So as the subject states I need to be able to answer a phone call programmatically in Android 4.0.3 on an HTC OneX. I have read several places that the MODIFY_PHONE_STATE
permission has been revoked by Google so to do this task you need a work around.
I have looked into two avenues so far:
(1) Following Guy's post here and using a BroadcastReceiver
(2) Using the following code to try and hit a key event through a shell command.
final Runtime r = Runtime.getRuntime();
try {
Process process = r.exec("input keyevent 5");
InputStream stream = process.getErrorStream();
log.v("Process Error Stream: " +stream.toString());
log.v("Sending shell command to Answer Call");
} catch (Exception e) {
log.v("Stack Trace: " + e.getStackTrace().toString());
e.printStackTrace();
}
I use this because keyevent 5 is KeyEvent.CALL according to Google and it works in adb using
adb shell input keyevent 5
My question is, what am I doing wrong? Because logically both of these methods makes sense but neither are working or even generating runtime errors of any kind.
Cheers