android - AlarmManager going off before Set Time -
i'm having issue alarmmanger:
the following correctly adds 1 day (because time 9:25 has passed) output correct yet alarmmanager calls broadcast within couple seconds. here's relevant snippit. ideas?
calendar cal = calendar.getinstance(); cal.set(calendar.hour_of_day, 21); cal.set(calendar.minute, 25); cal.set(calendar.second, 0); cal.set(calendar.millisecond, 0); intent intent = new intent(this, notificationreceiver.class); notificationreceiver instance = new notificationreceiver(); intent.setaction(instance.notification_send); intent.putextra("type",instance.notification_type_progress); intent.putextra("ticker","waiting arrival."); intent.putextra("id",1); intent.putextra("title","check-in"); intent.putextra("message","a message"); if(system.currenttimemillis()>cal.gettimeinmillis()){ if(cal.get(calendar.day_of_week) == calendar.saturday||cal.get(calendar.day_of_week) == calendar.sunday||cal.get(calendar.day_of_week) == calendar.friday){ cal.add(calendar.day_of_week,calendar.monday); log.d("alarms","set monday."); } else{ cal.add(calendar.date,1); log.d("alarms","set tomorrow. "+cal.get(calendar.day_of_month)); } } pendingintent pendingintent = pendingintent.getbroadcast(this.getapplicationcontext(), 24332, intent, 0); alarmmanager alarmmanager = (alarmmanager) getsystemservice(alarm_service); alarmmanager.setrepeating(alarmmanager.rtc_wakeup,cal.gettimeinmillis(),4000,pendingintent);
resolved:
pendingintent pendingintent = pendingintent.getbroadcast(this.getapplicationcontext(), 24, intent, pendingintent.flag_update_current);
Comments
Post a Comment