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
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.
Correct URI starting from API 9 is "content://com.android.deskclock/alarm". I'm still resolving the permission problem however.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With