问题
I am making this app just for me, with api 9 and stock alarm clock.
I found this: http://code.google.com/p/android-alarm-database/
and in on create of my main activity is this:
ContentResolver cr = getContentResolver();
AlarmDatabase ad = new AlarmDatabase(cr);
Record r = ad.getNearestEnabledAlarm();
When i use URI content://com.android.alarmclock/alarm it gives me in logcat:
Cannot resolve provider for content://com.android.alarmclock/alarm
Failed to find provider info for com.android.alarmclock
And than i tried with content://com.android.deskclock/alarm:
Permission denied: checkComponentPermission() reqUid=10009
Permission Denial: opening provider com.android.deskclock.AlarmProvider from ProcessRecord{407cf3b0 15716:com.my.app/10137} (pid=15716, uid=10137) requires null or null
回答1:
Correct URI starting from API 9 is "content://com.android.deskclock/alarm". I'm still resolving the permission problem however.
回答2:
Note that the Permissions of a alarms.db file in /data/data/com.android.alarmclock/databases/alarms.db (API 7-8) or /data/data/com.android.deskclock/databases/alarms.db (API 9-15) is -rw-rw----.
By this thing we cannot access the db file, even with an idea of URIMatcher class.
Till API 8, we have no specialized class available for Alarms, but from API 9, we can set an Intent with loaded Extras to set an Alarm at approximate Time.
I am also searching for ways to get down to solve this problem, hope someone finds the complete solution to this mess.
回答3:
You can set the alarm by following code as developers provide a new class to set Alarm.Use this code
Intent i = new Intent(AlarmClock.ACTION_SET_ALARM);
i.putExtra(AlarmClock.EXTRA_HOUR, 11);
i.putExtra(AlarmClock.EXTRA_MINUTES, 37);
i.putExtra(AlarmClock.EXTRA_MESSAGE, "birthday");
startActivity(i);
its working properl.But still i didnt get how to disable a set alarm.Please help.
来源:https://stackoverflow.com/questions/9340622/cannot-resolve-provider-for-content-com-android-alarmclock-alarm