[英]How Enable/Disable Accessibility Service When Lock/Unlock Screen in Android
I created an accessibility service and made a window (using WindowManager) in fun onServiceConnected(), So i want to show a widget when the screen is locked and hide it when the screen is unlocked I try: val keyguard = this.getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager
and that make the widget didn't show when the user want it on unlocked screen.我创建了一个可访问性服务并在有趣的 onServiceConnected() 中创建了一个 window(使用 WindowManager),所以我想在屏幕锁定时显示一个小部件并在屏幕解锁时隐藏它我尝试: val keyguard = this.getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager
并且当用户想要它在解锁屏幕上时,使小部件没有显示。 I tryied also BroadcastReceiver()
by register/unregister it onCreate()/onDestroy()
of AccessibilityService class, but stopService()
in fun onReceive(p0: Context?, p1: Intent?)
not working, and i tried kill the process of AccessibilityService in BroadcastReceiver()
but not working (the process starts again after is killed) Pleaese help me: the goal is : show a widget when the screen is locked and hide it when the screen is unlocked programmatically我还尝试通过在 AccessibilityService class 的onCreate()/onDestroy()
上注册/取消注册BroadcastReceiver()
,但是在fun onReceive(p0: Context?, p1: Intent?)
中的stopService()
不起作用,我尝试杀死进程BroadcastReceiver()
中的 AccessibilityService 但不起作用(该过程在被杀死后重新开始)请帮助我:目标是:在屏幕锁定时显示一个小部件,并在以编程方式解锁屏幕时隐藏它
I found the answer: https://stackoverflow.com/a/45100001/15772513 I put it on the Accessibility Service class and call disableSelf()
when the screen is unlock, and call that function in OnCreate() of AccessibilityService class. I found the answer: https://stackoverflow.com/a/45100001/15772513 I put it on the Accessibility Service class and call disableSelf()
when the screen is unlock, and call that function in OnCreate() of AccessibilityService class.
I hope this will help you.我希望这能帮到您。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.