I have used below code to schedule an alarm in my android application.
/**
* To set the alarm service to be fire on OFF mode
*/
public void setOffModeAlarmService() {
int offModeStartHour = 8;
int offModeStartMinute = 30;
Calendar offModeTime = Calendar.getInstance();
offModeTime.setTimeZone(TimeZone.getTimeZone(Constants.TIME_ZONE));
offModeTime.set(Calendar.HOUR_OF_DAY, offModeStartHour);
offModeTime.set(Calendar.MINUTE, offModeStartMinute);
mAlarmManager.setRepeating(AlarmManager.RTC_WAKEUP,
offModeTime.getTimeInMillis(), AlarmManager.INTERVAL_DAY,
getOffModeAlarmPendingIntent());
mAppUtilInstance.logDebugMessage(TAG, "OFF Mode Alarm Scheduled.");
}
I scheduled an alarm for every day. But If switch off my mobile some time before of alarm time, then My mobile is not waking up at the scheduled time.
Even I tried using WakefulBroadcastReceiver and also acquired the WakeLock. But nothing helps.
Please help me on this.