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
精彩评论