Android floating windows combined with FLAG_SHOW_WHEN_LOCKED not working

My application shows a user dialog in front of the lock screen. This is a simple operation that contains DialogFragments (from the support library, since this application runs on 2.2+).

Since the actual activity displaying these dialogs was not a floating window by Android standards,

getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); 

worked fine.

However, I thought that I would use an Activity that looks like Dialog. However, all Dialog themes (Holo, etc.) have this element:

 <item name="android:windowIsFloating">true</item> 

This for some reason causes the window flag to be completely ignored. Interestingly, the activity is displayed after the user unlocks the screen.

Why is this so, and is there a way around it?

+7
source share
1 answer

Suffering from the same problem. The only thing that works in this issue is

 KeyguardManager myKeyGuard = (KeyguardManager)getSystemService(Context.KEYGUARD_SERVICE); myLock = myKeyGuard.newKeyguardLock("tagName"); myLock.disableKeyguard(); 

Remember to use keyguard permission in the manifest:

 <uses-permission android:name = "android.permission.DISABLE_KEYGUARD"/> 
+4
source

All Articles