How to handle Alarm notification in Android?

Asheesh Vashishtha picture Asheesh Vashishtha · Apr 26, 2010 · Viewed 10.3k times · Source

I'm developing an media player application for Android, for which I need to handle any Alarm notification, and based on that I'll pause my playback. When the Alarm in snoozed or dismissed, I'll then resume the playback.

I googled a lot for the Alarm handling, but what I found was the way to enable Alarm notifications through code, set the intent and then handle it. However, no where could I locate just handling the Alarm notification part. I don't need to set the Alarm on, it could've been set by the user, and I don't need to programmatically. All I need is just handle that notification.

Any ideas on this would be extremely useful?

Thanks, Asheesh

Answer

JaVadid picture JaVadid · Jun 17, 2010

HI Asheesh Vashishtha,

Correct me on this, but AFAIK whenever any other application even if it is the alarm clock, is activated, your activity will surely go in background. So i guess u can override the OnPause and OnResume functions to put your bit of code. As far as snooze or other things are concerned, they all will result in the Alarm Activity getting destroyed(or paused, don know much about it) and your activity will get resumed. So that wont be a matter of concern for u!

Hope this helps...