I don't know if the title clear or not, my problem with the notification manager is that when I set the times as ( 1:00 , 2:00 , 3:00 , 4:00) and the time now is 2:30, the normal notification will wait until 3:00 then 4:00 ,, but in my code the notification manager give me two alert for 1:00 and 2:00 because the are in past , then wait until 3:00 and notify then 4:00 and notify, so my problem is with the times in past I don't want to get notification for them.
my code Main class.java , alertTimes is an array that have the times in millisecond
for (int i = 0; i < alertTimes.length; i++) {
inte = new Intent(this, AlertMedicine.class);
inte.putExtra("id", i);
inte.putExtra("name", NameOftimes[i]);
alarmManager.set(AlarmManager.RTC_WAKEUP, alertTimes[i], PendingIntent.getBroadcast(this, 1, inte, PendingIntent.FLAG_UPDATE_CURRENT));
}
AlertReceiver.java
createNotification(context, "OK", "OK", "OK" + j, 1, 0);
I also try in AlertReceiver.java to do this but this also not work
if(calendar.get(Calendar.HOUR_OF_DAY)< Integer.parseInt(arr[id].substring(0, 2))) {
createNotification(context, "OK", "OK", "OK" + j, 1, 0);
}
else
if(calendar.get(Calendar.HOUR_OF_DAY)== Integer.parseInt(arr[id].substring(0, 2))){
int min=Integer.parseInt(arr[id].substring(3, 5))+2;
if(calendar.get(Calendar.MINUTE) <= min){
createNotification(context, "OK", "OK", "OK" + j, 1, 0);