The problem is that if I give the manager a wake-up time, say 07:00, and now 22:25, it will work instantly, if I specify 23:00, it will work at a specified time. How to make it work tomorrow at 07:00? I understand that the easiest way is to explicitly specify the calendar variable, but are there any other options if I, for example, “don't know” what day and year it is now?

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

    2 answers 2

    You can not not know the current system time, incl. because then alarmManager will not be able to work, because it will not know when it will work.

    You need to compare the time value you specified with the current one, and if it is less (that is, it’s already passed), then you need to add a day to the specified time.

      calendar.set () - set the date and time

      there must be a setWhen method (calendar.getTimeInMillis) on the AlarmManager. Try it