获取闹钟应用中保存的所有闹钟

发布于 2024-09-07 05:29:46 字数 82 浏览 7 评论 0原文

是否有可能获得保存在 Android 闹钟应用程序中的闹钟列表?我正在制作一个应用程序,只需要显示“警报”应用程序中设置的警报。

谢谢

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

心意如水 2024-09-14 05:29:47

这篇文章对此有很好的解释。无法保证 AlarmClock 应用程序将出现在安装了您的应用程序的每台设备上。例如,许多 HTC 手机都将其替换为 HTC 自己的“世界时钟”应用程序。

但是,假设存在现有的 AlarmClock 应用程序,您应该能够从其内容提供商获取光标。请参阅此项目作为示例。

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.

痕至 2024-09-14 05:29:47
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());
    }
}

使用此代码...您将获得所有详细信息。享受!

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!

吻风 2024-09-14 05:29:47

出于调试目的,您可以使用“adb
shell dumpsys 警报”来自控制台。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文