So I'm trying to add a feature in my app to launch the alarm clock and set one, I tried it using the usual code:
Intent i = new Intent(AlarmClock.ACTION_SET_ALARM);
i.putExtra(AlarmClock.EXTRA_MESSAGE, "New Alarm");
i.putExtra(AlarmClock.EXTRA_HOUR, 10);
i.putExtra(AlarmClock.EXTRA_MINUTES, 30);
startActivity(i);
And it worked fine, the only issue is that the AlarmClock.EXTRA_HOUR param can be from 0 to 24 meaning I will be setting an alarm at best in the next 24 hours, but let's say I'm on Monday and I want to set an alarm on Friday, is there any way to do it?
I went over the AlarmClock documentation on Android Developers and found only the following optional params:
EXTRA_HOUR (optional): The hour of the alarm being set.
EXTRA_MINUTES (optional): The minutes of the alarm being set.
EXTRA_DAYS (optional): Weekdays for repeating alarm.
EXTRA_MESSAGE (optional): A custom message for the alarm.
EXTRA_RINGTONE (optional): A ringtone to play with this alarm.
EXTRA_VIBRATE (optional): Whether or not to activate the device vibrator for this alarm.
EXTRA_SKIP_UI (optional): Whether or not to display an activity for setting this alarm.
Any help would be appreciated
You could use EXTRA_DAYS
and enable the alarm only on the day (or days) you want it. This creates a repeating alarm, so you'll need to cancel it after it gets triggered if you don't want it to repeat.