I was trying to write an app which needs the user to set an alarm. I tried to call the alarm clock with the intent using following code
Intent i = new Intent(AlarmClock.ACTION_SET_ALARM);
i.putExtra(AlarmClock.EXTRA_MESSAGE, "MMTS train to catch rush up ...");
i.putExtra(AlarmClock.EXTRA_HOUR, d.getHours());
i.putExtra(AlarmClock.EXTRA_MINUTES, d.getMinutes());
activity.startActivity(i);
exception is
Permission Denial: starting Intent { act=android.intent.action.SET_ALARM
cmp=com.android.deskclock/.HandleSetAlarm (has extras) } from
ProcessRecord{414d1210 812:com.arjun.android.mmts/10041} (pid=812, uid=10041)
requires com.android.alarm.permission.SET_ALARM
I am working on Android 4.0 API version 14.
I added the line
<uses-permission android:name="android.permission.SET_ALARM"></uses-permission>
in my manifest file, even after that it was not working.
You need to declare the offending permission in your manifest: