Q:

Alarm rings, options displayed, then user presses home

I have written an alarm program which works nicely in most regards. When the alarm rings the user is presented with three options to select:

Stop
Snooze
Reschedule

The user then selects their choice, the alarm stops and what happens next depends on which option they selected.
But now I have a problem. Say the alarm goes off and the user accidentally presses the home button whilst fishing their phone out of their pocket. Now the alarm is still ringing, but the app is no longer in display! I don't know how to avoid this scenario. Any ideas?

A:

If you use activity as dialog, and if home button is pressed causing activity to close,  you can simply put alarm's stop method in onstop()  method of activity.

