开发者

how to handle lock screen button input for android activity?

Suppose I have something like an alarm activity which launches the alarm through the lock screen, accomplished via

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

Now, from here I could press the back button to kill the activity, but I also want a press of the lock button to silence the alarm. How would I go about creating a handler for presses of the开发者_运维知识库 lock screen button?


Listen to this broadcast intent

ACTION_SCREEN_OFF

You can switch off your alarm when you get this intent

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜