AlarmManager doesn't work at a given time.



  • Problem is, if I tell the manager time of awakening, it's 07:00, and now it's 22:25, it'll work instantly, if I say 23:00, it'll work in a given time. How do you make it work tomorrow at 0700? I understand that the simplest way to point out this is clearly variable. calendarBut is there any other option, if I say, "I don't know" what day and year?

    calendar.set(Calendar.HOUR_OF_DAY, timePickerHours);
    calendar.set(Calendar.MINUTE, timePickerMinutes);
    alarmManager.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), pendingIntent);
    


  • You don't know the current time of the system, because then the alarm Manager won't work, because he won't know when to work.

    You need to compare the time you have given to the current, and if it's less (i.e., it's already gone), then you need to add a day to the given time.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2