How do you launch an activity when the lock screen is enabled? I want to be able to launch an activity as a result of the screen being locked. I already no I can make an activity work on top of the lock screen using WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
but it is a little unclear to me how to start the activity when the screen is locked. Do I need a service to be running that listens for the screen to lock and then launches the activity?
Asked
Active
Viewed 1,973 times
0

Andrew Hubbs
- 9,338
- 9
- 48
- 71
1 Answers
0
When the lock screen is enabled, you should programmatically unlock first the screen and launch the activity you want. After that, you can lock again the screen or do whatever you want. Maybe you can use a broadcast listener for lock screen if there is. You could try ACTION_SCREEN_OFF or create a service.

iamtheexp01
- 3,446
- 9
- 35
- 35
-
Is there a way to do this without a persistently running service? I know it is bad practice to keep a service running indefinitely but I don't know another way to do this a the moment. – Andrew Hubbs Mar 02 '11 at 17:40
-
You can try the broadcast listener ACTION_SCREEN_OFF, not sure if it works. – iamtheexp01 Mar 03 '11 at 05:32