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

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -