简体   繁体   English

android> = 23 Level Api中的自动接听电话

[英]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) 1)使用专用API进行了尝试(结束呼叫无法正常工作,但没有应答电话)

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)? 2)使用SendOrderedBroadcast和本文中提到的其他各种方法如何在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 如果我使用私有api,则会引发SecurityException(要求MODIFY_DEVICE_STATE权限),如果我在上述文章中使用方法,则会显示以下警告

"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 }" “由于没有窗口焦点而取消了事件:KeyEvent {action = ACTION_UP,keyCode = KEYCODE_HEADSETHOOK,scanCode = 0,metaState = 0,标志= 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. 如果有此问题的解决方法,请帮助我,我正在使用Android版本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. 1)您需要具有“ DRAW OVER OTHER APPS”的访问权限,即“屏幕覆盖”权限,这还将在清单中包括android.permission.SYSTEM_ALERT_WINDOW权限。

2) You need to implement a Broadcast Receiver to check for the incoming call. 2)您需要实现一个广播接收器来检查来电。

3) When an CALL_STATE_RINGING is detected, start a new activity that draws over other applications, using WindowsManager. 3)当检测到CALL_STATE_RINGING时,使用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. 4)还可以使用此活动来使用应答方法,因为您的应用程序位于顶部和底部,所以此方法将起作用。

5) Kill this activity and if needed open your project from this activity and then kill this activity. 5)终止该活动,并在需要时从此活动中打开您的项目,然后终止该活动。

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设备中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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