Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android's floating windows coupled with FLAG_SHOW_WHEN_LOCKED fails

My app, shows a dialog box to the user before the lock screen. It's a simple Activity that contains DialogFragments (from the support library as this app runs on 2.2+).

Since the actual activity that displayed those dialogs was not a floating window by Android's standards,

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

worked fine.

However, I was thinking I'd use an Activity that looks like a Dialog instead. All the Dialog themes (Holo, etc), though, have this item:

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

This, for some reason causes the window flag to be completely ignored. Interestingly, the Activity gets shown after the user unlocks the screen.

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

like image 946
A--C Avatar asked Nov 16 '12 05:11

A--C


People also ask

How do I force a floating window in Android?

For Funtouch OS 3.0 and higher version, you can go to Settings>More settings>Permission management(Applications)>Floating window to turn on/off the floating window of your apps.

How do I enable floating window on my Motorola?

Open the first app. Drag up from the bottom of the home screen, hold, then release. Or, touch if you're using 3-button navigation. Be sure to touch the app's icon instead of the preview, which opens the app.


1 Answers

Suffering from the same issue. The only thing that seems to work in this issue is

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

Dont forget to use the keyguard permission in manifest:

<uses-permission android:name = "android.permission.DISABLE_KEYGUARD"/>
like image 65
Himanshu Virmani Avatar answered Oct 21 '22 04:10

Himanshu Virmani