android - Alarmmanager firing several times -
i have asked before , god knows have tried suggested. trying have service executed once day @ given time daily. able set alarm , broadcasts. reason when alarm gets fired, 13h30, it's gonna fired thereon @ several irregular intervals. thing that's working having alarm fire @ correct time first, fire throughout day , it's driving me crazy. please help.
pendingintent reviewspendingintent = pendingintent.getbroadcast(this,0,new intent(this,reviewreceiver.class),pendingintent.flag_update_current); alarmmanager alarmmanager = (alarmmanager)(this.getsystemservice(context.alarm_service)); calendar cur_cal = new gregoriancalendar(); cur_cal.settimeinmillis(system.currenttimemillis()); random random = new random(); int low = 7; int high = 22; int hour = random.nextint(high - low) + low; int minute = random.nextint(60 - 10) + 10; calendar cal = new gregoriancalendar(); cal.set(calendar.hour_of_day, 13); cal.set(calendar.minute,15); cal.set(calendar.second,5); cal.set(calendar.millisecond,0); if(cal.gettimeinmillis() >= system.currenttimemillis() ) { log.i(tag,"set today"); alarmmanager.setrepeating(alarmmanager.rtc_wakeup, cal.gettimeinmillis(), alarmmanager.interval_day, reviewspendingintent); }else{ log.i(tag,"set tomorrow"); cal.set(calendar.date,1); alarmmanager.setrepeating(alarmmanager.rtc_wakeup, cal.gettimeinmillis(), alarmmanager.interval_day, reviewspendingintent); }
n.b. plan use random integers set alarm when working properly.
Comments
Post a Comment