I am working on an alarm clock program (for me as a learning project. There are plenty of alarm clocks in the market). What should be the expected behavior when the alarm sounds when my device is locked with a pattern lock? When the alarm sounds and the device is unlocked, a dialog appears along with the sounds. Certainly, this dialog would not be able to show over the pattern lock, correct? Is this the type of thing that perhaps I could write a lock screen widget to allow interaction with the sounding alarm? Any other clever options to allow the user to disable an alarm while the device is locked? Just looking for ideas and guidance here.
Asked
Active
Viewed 3,790 times
3 Answers
2
You are incorrect...I do this in one of my apps. All you need to do is set a few flags in your activity, such as
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
see this post:
-
Wow! I had no idea. I thought for sure this would be some sort of security breach, and therefore prohibited. Thanks :) – MrGibbage Apr 30 '13 at 12:34
-
I originally thought the same thing, myself. Glad I can help! – dberm22 Apr 30 '13 at 14:50
1
the expected behavior is to have a button on screen that can stop the sound ASAP. Imagine you when you just wake up, still sleepy, trying to figure the unlock pattern AND THEN to find the widget to stop the sound... I don't care if my phone was locked or no, i want to shut down the damn alarm at once.
In short, give the user the chance to stop the sound with 1 touch. If necessary, unlock the screen: it will result less annoying than having to explore the phone while it's screaming around at 6AM

STT LCU
- 4,348
- 4
- 29
- 47
1
1.You should not use Dialog theme. 2. You should use full Screen theme.
Here is code :
@Override
public void onAttachedToWindow() {
Window window = getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
| WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
| WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
| WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
| WindowManager.LayoutParams.FLAG_FULLSCREEN);
super.onAttachedToWindow();
}

user3911501
- 39
- 1
- 6