java - AlarmManager not started at specified timing -


i having problem when trying start alarm manager in android send push-notifications upon condition.

so trying have list of events, system send push notification on events' eve. , here part grab event date , make comparison:

for (int count = 0; count < _eventlist.size(); count++) {          date alarmdate = null;         try {             alarmdate = dateformat.parse(_eventlist.get(count)                     .geteventdate());         } catch (parseexception e) {             e.printstacktrace();         }         calendar calendar = calendar.getinstance();         calendar.settime(alarmdate);         calendar.add(calendar.date, -1);         date alarmbeforeoneday = calendar.gettime();         calendar.add(calendar.date, 1);          if (dateformat.format(alarmbeforeoneday).equals(currentdate)) {             if (!alarminitialized(context)) {                 notifyeventname = _eventlist.get(count).geteventname();                 notifyeventtime = _eventlist.get(count).geteventtime();                 notifyeventaddress = _eventlist.get(count).geteventaddress();                 notifyeventpic = _eventlist.get(count).geteventpic();                 schedulealarms(context);             }         }     } 

if today event's eve, execute schedulealarm() start broadcast receiver:

public static void schedulealarms(context context) {     int day = calendar.getinstance().get(calendar.date);     int month = calendar.getinstance().get(calendar.month);     int year = calendar.getinstance().get(calendar.year);     simpledateformat df = new simpledateformat("yyyy-mm-dd hh-mm");     string time = year + "-" + month + "-" + day + " " + "00" + "-" + "30";      date dt = null;     try {         dt = df.parse(time);     } catch (parseexception e) {         e.printstacktrace();     }     long when = dt.gettime();      alarmmanager mgr = (alarmmanager) context             .getsystemservice(context.alarm_service);     intent notificationintent = new intent(context, alarm.class);     notificationcount = notificationcount + 1;      notificationintent.putextra("notifycount", notificationcount);     notificationintent.putextra("eventname", notifyeventname);     notificationintent.putextra("eventtime", notifyeventtime);     notificationintent.putextra("eventaddr", notifyeventaddress);     notificationintent.putextra("eventpic", notifyeventpic);     pendingintent pi = pendingintent.getbroadcast(context, 3,             notificationintent, pendingintent.flag_update_current);     mgr.set(alarmmanager.rtc_wakeup, when, pi); } 

so push notification part working perfectly. did received it. however, push notification shows when launch activity.

it not send according timing have set in method previously. in case, supposed send push notification @ 12:30 if today event's eve. however, code, when reaches 12:30 , not send. send when run activity itself.

any guides/ideas? in advance.

are trying send notification activity or service? mean context of executing schedulealarms(context context) ?


Comments

Popular posts from this blog

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -