Android get list of active alarms

一曲冷凌霜 提交于 2019-12-03 22:18:31
Uncaught Exception

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.

Steven Trigg

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.

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

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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!