1

i want to get the alarm in the Clock Application in the mobile iam using the following code

Uri uri = Uri.parse("content://com.android.deskclock/AlarmClock");
        Cursor c = mContext.getContentResolver().query(uri, null, null, null,null);
        if (c != null) {
            String names[] = c.getColumnNames();
            for (String temp : names) {
                System.out.println(temp);

            }

            if (c.moveToFirst()) {
                do {
                    int i = 0;
                    for (int j = 0; j < c.getColumnCount(); j++) {
                    }
                } while (c.moveToNext());
            }
        }

iam getting the following Exception

java.lang.SecurityException: Permission Denial: opening provider 
com.android.deskclock.AlarmProvider from ProcessRecord{4162b268 
12999:com.genie9.gcloudbackup/10059} (pid=12999, uid=10059) that is not exported from uid 10011

does any one knows what is the permission that i have to use here? i have searched alot and couldn't find anything usefull, thanks for helping

AnasBakez
  • 1,230
  • 4
  • 20
  • 36

1 Answers1

1

You can set an alarm using Alarm class see here

or You can not access this uri. but you can use below code to set an alarm with Alarm Clock,

Intent i = new Intent(AlarmClock.ACTION_SET_ALARM);
    i.putExtra(AlarmClock.EXTRA_HOUR, 9);
    i.putExtra(AlarmClock.EXTRA_MINUTES, 37);
    startActivity(i);

You ll need to add permission in manifest given below

<uses-permission android:name="com.android.alarm.permission.SET_ALARM"/>
AAnkit
  • 27,299
  • 12
  • 60
  • 71
  • 1
    no i dont want to use intents and use the Alarm Clock Application, i want to read all the alarms set in the device not adding one, is there any way to do this? – AnasBakez Jul 16 '12 at 06:19