Try with the AlarmManager.setExact()
AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
am.setExact(AlarmManager.RTC_WAKEUP, c.getTimeInMillis(), pendingIntent);
Question
I realize that this alarm triggers even after finish time in android is a similar question. However, mine's got a little bit different.
I wonder, for example, if i set time to be 14:40, and launch the app at 15:00 (or any other time after 14:40:00), the alarm manager's onReceive method will be triggered immediately.
Actually, this is a confirmation rather than a question since my application seems to do this.
Thank you !
CODE
Calendar c = Calendar.getInstance();
c.set(Calendar.HOUR_OF_DAY, 14);
c.set(Calendar.MINUTE, 40);
c.set(Calendar.SECOND, 0);
//System.out.println();
AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
am.set(AlarmManager.RTC_WAKEUP, c.getTimeInMillis(), pendingIntent);
Solution
Try with the AlarmManager.setExact()
AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
am.setExact(AlarmManager.RTC_WAKEUP, c.getTimeInMillis(), pendingIntent);