如何获取Android手机中的闹钟数?

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

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

但是当我尝试使用获取数字时,我得到一个NullPointerException

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

请让我知道我做错了什么? getCount()本身发生exception,因此我无法显示警报的数量。

编辑:我也在我的LogCat上收到此消息:

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

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