Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to show popup Activity or Dialog when phone is locked?

Tags:

android

I am trying to show a activity or a dialog when the phone is locked. I have tried using a WakeLock but it did not work and I can only see the activity once my phone is unlocked?

What is the proper way to do this?

like image 304
Jason Avatar asked Sep 28 '10 13:09

Jason


People also ask

How do I show activity on lock screen?

To enable it you have to go to the app configuration -> Other permissions -> Show On Lock screen. The full screen activity will also not appear if you have an existing notification with the same id that has not been dismissed.

How to create popup activity in Android?

If you want to do this using an Activity instead of a Dialog, you can do this by setting the activity's theme to android:theme="@android:style/Theme. Dialog" in the manifest - this will make the activity appear like a dialog (floating on top of whatever was underneath it).

How do I show push notifications on Android lock screen?

Open your phone's Settings app. Notifications. Under "Lock screen," tap Notifications on lock screen or On lock screen. Choose Show alerting and silent notifications.


1 Answers

To show activity without dismissing the keyguard try this:

getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
setContentView();
like image 157
HarryHao Avatar answered Sep 28 '22 09:09

HarryHao