Home » Android » android – How to set Alarm using alarm clock class

android – How to set Alarm using alarm clock class

Posted by: admin June 15, 2020 Leave a comment


Hi I am trying to set Alarm in my application Using the AlarmClock class. I am using the code as follows:

 Intent intent = new Intent();

But I am getting an exception. Can anyone please tell how to use this new Android feature?

How to&Answers:

You’ll also need to add

<uses-permission android:name="com.android.alarm.permission.SET_ALARM"/>

to your manifest.


Ollie is right, the code should look something like the following:

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


You need to specify the time when the alarm is being set for:


You’re asking Android to set an alarm without telling it when, so add extra intent bundle parameters for Hour & Minutes and then I expect it will work (it is hard to be sure as you’ve provided no information about the exception).