Reason: Android can be used to aidl silent answer, but after 5.0 was Google to shield, this time we can only be achieved by other means. Solution:
try { runtime.getruntime (). EXEC ("input keyevent" + integer.tostring (Keyevent.keycode_headsethook)); } catch (IOException e) { //runtime.exec (String) had an I/O problem, try to fall back String enforcedperm = "Androi D.permission.call_privileged "; Intent Btndown = new Intent (Intent.action_media_button). PutExtra ( intent.extra_key_event, New KeyEvent ( Keyevent.action_down, Keyevent.keycode_headsethook)); Intent btnup = new Intent (Intent.action_media_button). PutExtra ( intent.extra_key_event, New KeyEvent ( KEYEVENT.ACTION_UP, Keyevent.keycode_headsethook)); Mcontext.sendorderedbroadcast (Btndown, enforcedperm); Mcontext.sendorderedbroadcast (Btnup, enforcedperm); }
Simply put is to send a headset to press the event to listen, to deceive the system.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
[Android] Android5.0 implementation of Silent answer call function