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
            Asked
            
        
        
            Active
            
        
            Viewed 833 times
        
    0
            
            
         
    
    
        TAHAR Noureddine
        
- 24
- 6
1 Answers
0
            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.
 
    
    
        TAHAR Noureddine
        
- 24
- 6