android - Notification at specific time -


i have notification @ specific time, see code:

//create alarm manager  alarmmanager alarmmgr0 = (alarmmanager)getsystemservice(context.alarm_service);   //create pending intent & register alarm notifier class  intent intent0 = new intent(this, alarmreceiver_maandag_1e.class);  intent0.putextra("uur", "1e");   pendingintent pendingintent0 = pendingintent.getbroadcast(this, 0, intent0, 0);   //set timer want alarm work (here have set 8.30)  calendar timeoff9 = calendar.getinstance();  timeoff9.set(calendar.hour_of_day, 8);  timeoff9.set(calendar.minute, 30);  timeoff9.set(calendar.second, 0);   //set timer rtc wakeup alarm manager object  alarmmgr0.set(alarmmanager.rtc_wakeup, timeoff9.gettimeinmillis(), pendingintent0); 

this works perfect except 1 thing.

the notification set 8:30 alarm manager if launch app after 8:30, 9:00 example, notification still shows..

is there possibility alarm goes off @ 8:30 not later?

edit

for having same problem, here solution:

put in broadcastreceiver:

long current_time = system.currenttimemillis();  calendar timeoff9 = calendar.getinstance(); timeoff9.set(calendar.hour_of_day, 8); timeoff9.set(calendar.minute, 35); timeoff9.set(calendar.second, 0);  long limit_time = timeoff9.gettimeinmillis();  if (current_time > limit_time) {     //nothing } else {     //show notification } 

you can try method of alarm manager:

public void setexact (int type, long triggeratmillis, pendingintent operation) 

but requiers api level 19.


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -