java - AlarmManager firing Alarm Instantly -


intent myintent = new intent(alarm.this, automaton.class);                   myintent.putextra("methodname", "mymethod");                   myintent.putextra("hour", tp.getcurrenthour().tostring());                   myintent.putextra("minute", tp.getcurrentminute().tostring());                   hour = tp.getcurrenthour();                   minute = tp.getcurrentminute();                   pendingintent pendingintent = pendingintent.getactivity(alarm.this, 0, myintent,pendingintent.flag_update_current);                   alarmmanager alarmmanager = (alarmmanager)getsystemservice(alarm_service);                        calendar calendar = calendar.getinstance();                        calendar.set(calendar.hour_of_day, hour);                        calendar.set(calendar.minute, minute);                        calendar.set(calendar.second, 0);                         alarmmanager.setrepeating(alarmmanager.rtc_wakeup, calendar.gettimeinmillis(), 86400000, pendingintent); 

above code. here problem; have method in activity want run @ specified time. if user selects time hasn't passed yet in day (say set alarm @ 10am 11am, work fine). however, if set alarm 9am @ 10am, instantly fire pending intent. not sure going wrong. appreciated!

you might need check whether set time less current time. if set time less current time, don't set alarm it. because it's useless if keep when time has passed.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -