K
K
Konstantin Dovnar2015-10-23 19:51:37
Android
Konstantin Dovnar, 2015-10-23 19:51:37

Launching Alert earlier than necessary?

If you set some action to AlertManager'u through Calendar and the time is less than the one on the device at the moment, then the specified action will be performed now.
Those. asking

Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 30);
calendar.set(Calendar.SECOND, 0);

but if there is already more time than half past one, then the action will be executed immediately.
I understand that this is happening because the date is the same as today, i.e. it is enough to change the date to the next day, but this will have to perform an extra check [if the last day of the month, then set the first]. Maybe there is some normal way to get around this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Varakosov, 2015-10-23
@thelongrunsmoke

If you make a simple alarm clock, then there is a completely different class
developer.android.com/intl/ru/reference/android/pr ... reference/java/util/...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question