1

Is there a way to to receive a broadcast(System broadcast,may be) in android as soon as user of the phone sets an Alarm?

I googled this and most of the discussion on stackoveflow seems to be around how to check if alarm is already set using AlarmManager class and how this can or cannot be done etc.

I guess my requirement is little different, because I want to register a BroadcastReciver through my app, which should be notified as soon as user sets an Alarm. Even if user sets multiple alarm, my app should be notified for each alarm, set by the user.

I am also ok for any other way beside BroadcastReciver too for this, if one exist in Android.

Update: I tried android.app.action.NEXT_ALARM_CLOCK_CHANGED with my BroadcastReceiver after the suggestion from PeterChaula and it worked. But that this ACTION_NEXT_ALARM_CLOCK_CHANGED was introduced in API Level 21 and my app needs to support minSdkVersion of 14 and above.

Cœur
  • 37,241
  • 25
  • 195
  • 267
AADProgramming
  • 6,077
  • 11
  • 38
  • 58
  • this broadcast could be useful to you - `android.app.action.NEXT_ALARM_CLOCK_CHANGED` but it's only 21+ – Peter Chaula Oct 16 '16 at 11:58
  • @PeterChaula let me quickly try with this broadcast. but ya, my app's minSdkVersion is 14. So I need another solution for sure... – AADProgramming Oct 16 '16 at 12:04
  • @PeterChaula I tried the `android.app.action.NEXT_ALARM_CLOCK_CHANGED` and it worked. But as I stated earlier I need the solution for minSdkVersion of 14 and above. – AADProgramming Oct 16 '16 at 12:14
  • You could maybe try observing `content://com.android.deskclock/alarm` but it's a bit inconsistent across manufacturers as some replace the default clock app with their own. – Peter Chaula Oct 16 '16 at 12:57

0 Answers0