How to launch an activity when lock screen is enab

2019-06-13 01:54发布

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?

1条回答
时光不老,我们不散
2楼-- · 2019-06-13 02:05

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.

查看更多
登录 后发表回答