I m using the alarm manager in my app and i want to repeat alarm after one day. the alarm should be invoked after one day when invoked once by time.Please help. Thanks in advance.
if(str_freqSchedule.equals(checkForDaily)){
Calendar calendar = Calendar.getInstance();
//calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR));
calendar.set(Calendar.HOUR_OF_DAY, hr);
calendar.set(Calendar.MINUTE, min);
calendar.set(Calendar.SECOND,0);
Intent intent = new Intent(this, AlarmReceiverActivity.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(
this.getApplicationContext(), j, intent, PendingIntent.FLAG_CANCEL_CURRENT);
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(),(24*60*60*1000),pendingIntent);
j++;
}
Hopefully below code will help, I used the same in my app. Here the argument passed in AlarmManager class for repeating should be 24*60*60*1000
It is better to use inexactrepeating instead of setExactRepeating keeping in mind of battery consumption as per android documentation.
Try this