tags:

views:

492

answers:

2

Hi,

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

A: 

AFAIK, there is no way for you to be notified of what the Alarm Clock application does, any more than you get notified about any other third-party alarm clock.

Note that AlarmManager -- what you were probably reading about -- is not the same as the Alarm Clock application.

Sorry!

CommonsWare
Hi CommonsWare, Thanks for your reply, however, I found the intent action using which I can be notified when the Alarm goes off. The intent actions string is "com.android.alarmclock.ALARM_ALERT". This works fine for me, however, I now need to handle the events generated by pressing the Snooze and Dismiss buttons in the Alarm clock. Any help on this would be useful. Thanks a lot,Asheesh
Asheesh Vashishtha
That `Intent` action is not part of the SDK -- nothing starting with "com.android" is part of the SDK. Do not rely upon that `Intent`. It may not be used on some devices (those that have replaced the standard Alarm Clock with a custom app). Also, it may not work on future versions of Android. http://www.androidguys.com/2009/12/14/code-pollution-reaching-past-the-sdk/
CommonsWare
Thanks a lot, CommonsWare. So what you're suggesting is that if we don't use the Intent action, there's no other way of handling the events generated by the Alarm clock application? Also, there's no such Alarm clock that's provided out-of-the box by the SDK? Is it something that has been added on top of it later? Please correct me on this.
Asheesh Vashishtha
"Also, there's no such Alarm clock that's provided out-of-the box by the SDK?" The SDK is a programming interface. It does not include apps, any more than the Windows SDK includes Notepad or Minesweeper.
CommonsWare
A: 

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...

JaVadid