AlarmManager with Calendar Object Android java

前端 未结 1 581
闹比i
闹比i 2020-12-12 04:38

Hello im trying to make a simple fully working alarm clock but im stuck on making proper alarms... what i dont understand is this :

https://developer.android.com/tra

相关标签:
1条回答
  • 2020-12-12 05:19

    we set current time in milis to the calendar so if we get time in milis it will fire right now what is the purpose of setting current time in milis and then assigning the hour and minute ?

    (Edit: not strictly true. getInstance() should set the time to the current date and time automatically - setting the time in millis is probably irrelevant here) - The purpose is to set the current year / month / day at the same time. If you only set the hour and and minute it is not obvious on which day that will fire.

    set time in milis sets the ammount of miliseconds from the year 1970 until now ?

    The current number of milliseconds since January 1st 1970 in the UTC timezone.

    calendar get time in milis returns the amount of milis since the hour we set? or ? i dont understand these lines at all, why do we set current time in millis and then set hour to fire?

    getTimeInMillis() in this case will return the number of milliseconds since January 1st 1970 in the UTC timezone, up to 08:30 of the current day.

    EDIT - if i set alarm to trigger at 10:00 and its 10:05 what should i do ? it fires imediately........

    It is possible that the time has already passed. Bear in mind the time is in UTC! If you are in America or Asia that could be significantly different to your interpretation of "now".

    0 讨论(0)
提交回复
热议问题