I have an issue with the AlarmManager API, it doesn't fire at all on my samsung device, but it works on other Android device...
My code is like that:
public void setAlarm(int hourAlarm, int minutesAlarm, int numeroAlarm, boolean yesOrNoRepeatAlarm) {
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, numeroAlarm, broadcastIntent, PendingIntent.FLAG_UPDATE_CURRENT);
Log.i("numeroAlarm", numeroAlarm + "");
Calendar calendar = Calendar.getInstance();
if( (calendar.get(Calendar.HOUR_OF_DAY) > hourAlarm) ||
( calendar.get(Calendar.HOUR_OF_DAY) == hourAlarm && calendar.get(Calendar.MINUTE) > minutesAlarm)) {
calendar.add(Calendar.DATE, 1);
}
calendar.set(Calendar.HOUR_OF_DAY, hourAlarm);
calendar.set(Calendar.MINUTE, minutesAlarm);
Log.i("timeInMillis", calendar.getTimeInMillis() + "");
Log.i("repeatingAlarm", yesOrNoRepeatAlarm + "");
if(yesOrNoRepeatAlarm) {
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), AlarmManager.INTERVAL_DAY, pendingIntent);
}
else {
alarmManager.setExact(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), pendingIntent);
}
}
It works perfectly on other device (specially on kitkat) but not on lolipop in my samsung device, do you have any idea please ?