I have an alarm that should run everyday at 12AM (it is not a repeating alarm, i am setting it each time i need cz in some cases i dnt want it to run)
Intent myIntent = new Intent(AlarmService.this, AlarmService.class);
pendingIntent = PendingIntent.getService(this, 0, myIntent, 0);
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
Calendar cal = Calendar.getInstance();
cal.set(Calendar.HOUR_OF_DAY, 12);
cal.set(Calendar.AM_PM, Calendar.AM);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
cal.add(Calendar.DAY_OF_MONTH, 1);
alarmManager.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), pendingIntent);
The weird thing is that if i change the date/time manually to 12Am of the next day the alarm is fired. But if i set time to 11:59Pm of today and wait till 12AM nothing happens and if the time/date was automatically set, it is also not firing at 12AM. Any idea why is that hapennning or how can i fix it? Thank you