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 un开发者_开发问答clear 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?
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.
精彩评论