如何获取Android手机的闹钟次数? [英] How to get the number of alarms in Android phone?

查看:35
本文介绍了如何获取Android手机的闹钟次数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用以下代码来获取手机上当前设置的闹钟数量.

I am trying to use the following code to get the number of alarms currently set on the phone.

Uri uri = Uri.parse("content://com.android.deskclock/AlarmClock");
Cursor c = getApplicationContext().getContentResolver().query(uri, null, null, null,null);

但是当我尝试使用

int num = c.getCount();
System.out.println("No of alarms : "+c.getCount());

请让我知道我做错了什么?异常发生在 getCount() 本身中,因此我无法显示警报数量.

Please let me know what I am doing wrong ? The exception occurs in getCount() itself so I am not able to display the number of alarms.

我也在我的 LogCat 上收到这条消息:

I also get this message on my LogCat :

ActivityThread(13290): Failed to find provider info for com.android.deskclock

推荐答案

您正在寻找的 Uricontent://com.android.deskclock/alarms,但您无法访问应用的 ContentProvider,因为它未导出.你只会抛出一个 SecurityException.

The Uri you're looking for is content://com.android.deskclock/alarms, but you can't access the app's ContentProvider because it isn't exported. You'll just throw a SecurityException.

这篇关于如何获取Android手机的闹钟次数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆