简体   繁体   中英

Auto answer call in android >=23 Level Api

I've tried a bunch of alternatives for auto answer incoming call.

1) Tried using Private API's (End call is working answer call doesn't)

2) Using SendOrderedBroadcast and various other methods that are mentioned in this post How can incoming calls be answered programmatically in Android 5.0 (Lollipop)?

If i use private api it is throwing SecurityException (Asking for the MODIFY_DEVICE_STATE permission) and if i use methods in the above post it is showing the below warnings

"Cancelling event due to no window focus: KeyEvent { action=ACTION_UP, keyCode=KEYCODE_HEADSETHOOK, scanCode=0, metaState=0, flags=0x20, repeatCount=0, eventTime=7550277, downTime=7550277, deviceId=-1, source=0x101 }"

Please help me if there is any workaround for this issue, im using Android Version 23.

Thanks in advance..

There will be some extra work to be done for this to work, to answer an incoming call.

1) You need to have access for "DRAW OVER OTHER APPS" ie Screen Overlay permission, this will also include android.permission.SYSTEM_ALERT_WINDOW permission in the manifest.

2) You need to implement a Broadcast Receiver to check for the incoming call.

3) When an CALL_STATE_RINGING is detected, start a new activity that draws over other applications, using WindowsManager. Also, set a wakelock in this activity to make the phone awake if in lockscreen mode.

4) Also use this activity for using answer call methods, this will work as now your application is on the top and in forground.

5) Kill this activity and if needed open your project from this activity and then kill this activity.

New solution is here, look on this question:

Programmatically accept call in Nougat

我已经通过在TelephonyManager中使用AnswerRingingCall函数解决了此问题,该功能将由电话状态侦听器(TelephonyManager.CALL_STATE_RINGING)触发,当您使用此方法时,它实际上会引发安全异常(向MODIFY_STATE权限询问),但是将绕过此异常通过将apk推送到/ system / priv-app在Rooted设备中

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM