Get all alarms saved in the alarm application

我是研究僧i 提交于 2019-11-27 12:32:33

问题


Is it by any chance possible to get a list of alarms saved in the alarm application of android ? I am making an application which just needs to show the alarms set in the Alarm application.

Thanx


回答1:


There is a good explanation on this post regarding this. There are no guarantees that the AlarmClock app will be on every device your app is installed on. For example, many of the HTC phones replace it with HTC's own "World Clock" app.

However, assuming the stock AlarmClock app is present, you should be able to get a cursor from its content provider. See this project as an example.




回答2:


final String tag_alarm = "tag_alarm";
Uri uri = Uri.parse("content://com.android.alarmclock/alarm");
Cursor c = getContentResolver().query(uri, null, null, null, null);
Log.i(tag_alarm, "no of records are " + c.getCount());
Log.i(tag_alarm, "no of columns are " + c.getColumnCount());
if (c != null) {
    String names[] = c.getColumnNames();
    for (String temp : names) {
        System.out.println(temp);
    }
    if (c.moveToFirst()) {
        do {
            for (int j = 0; j < c.getColumnCount(); j++) {
                Log.i(tag_alarm, c.getColumnName(j)
                        + " which has value " + c.getString(j));
            }
        } while (c.moveToNext());
    }
}

Use this code...and you will get all the details. Enjoy!




回答3:


For debugging purposes, you can use "adb shell dumpsys alarm" from the console.



来源:https://stackoverflow.com/questions/3147179/get-all-alarms-saved-in-the-alarm-application

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