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. 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
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.
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.