How to answer incoming call programmatically in Android
Here is example for accepting incoming calls programmatically
The most stable version is using adb shell feature.
Call can be answered by sending command “adb shell input keyevent 79” via Terminal
Same thing can be done programmatically.
But, it works good for user-driven answering and this solution good for custom call screen.
It will not work for any sort of automated call-control-type applications.
Like auto answering via BroadcastReceivers etc.
try { Runtime.getRuntime().exec("input keyevent " + Integer.toString(KeyEvent.KEYCODE_HEADSETHOOK)); } catch (IOException e) { //handle error here }
Awaiting comments. Let me know the better ways.
3 Comments
srijana karkidholi · 16 September, 2016 at 07:09
awesome
Peter · 13 January, 2017 at 15:03
This method is unfortunately dead in android 7.0. I have also one moto g 3. edition where it does not work on android 6.0 🙁 Any other ideas how to do this?
Igor Khrupin · 3 May, 2017 at 00:39
Peter, unfortunately no ideas 🙁