Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android get list of active alarms

Tags:

android

alarm

Is there any way to get a list of all the active alarms in the android device programmatically in our application programmatically.Just point me out to some links that can be of help I am basically trying to give the user the facility of viewing all the alarms in his device so i want to get a list of all the active alarms in the device.

like image 735
XylemRaj Avatar asked Feb 22 '14 04:02

XylemRaj


4 Answers

No, AFAIK you can't do that programmatically so showing that info to a user in UI is not feasible.

However for your own reference you can dump the alarm data via

adb shell dumpsys alarm

You don't need root permission for that.

But what you get from above could be very confusing to understand. In order to understand that dump completely you should check out morphatic's answer here.

like image 122
Uncaught Exception Avatar answered Oct 12 '22 00:10

Uncaught Exception


Short answer: you can't.

The alarm manager gives no visibility to the alarms currently scheduled in the system. Every app that uses alarm manager must persist the state of each alarm that they set.

However you can get a list via adb as described in this question Get list of active PendingIntents in AlarmManager. And an app could get a system dump and get the alarms that way but that would require root.

like image 29
Steven Trigg Avatar answered Oct 12 '22 01:10

Steven Trigg


If you mean by active alarms, the ones in the device's Alarm Clock Application, I think you can. Try checking out the methods from Here.

However, if you mean that you want to see all alarms created by AlarmManager on your device, then unfortunately you can not do it programatically.

But, you can view the dump data in a text file like this:

adb shell dumpsys alarm > dump.txt
like image 11
Mena Avatar answered Oct 11 '22 23:10

Mena


You can get the next alarm that is scheduled (docs)

getSystemService(AlarmManager::class.java).nextAlarmClock.triggerTime

Returns the time at which the alarm is going to trigger. This value is UTC wall clock time in milliseconds

like image 4
ulcica Avatar answered Oct 12 '22 00:10

ulcica