android - Notification disappears then reappears when clicked on? -
hi have notifcation set go off on specific day , time. here code -
private void createpushtimer() { // todo auto-generated method stub calendar calendar = calendar.getinstance(); intent intent = new intent(mainactivity.this, drawing.class); pendingintent pendingintent = pendingintent.getbroadcast(mainactivity.this, 2, intent, 0); alarmmanager = (alarmmanager)getsystemservice(alarm_service); int day = calendar.get(calendar.day_of_week); if (day == 4) { //5 thurs calendar.set(calendar.hour_of_day, 9); calendar.set(calendar.minute, 48); calendar.set(calendar.second, 0); am.setrepeating(alarmmanager.rtc_wakeup, calendar.gettimeinmillis(), alarmmanager.interval_day*7, pendingintent); } //am.setrepeating(alarmmanager.rtc_wakeup, 10000, alarmmanager.interval_day, pendingintent); }
here receiving class notification -
public void shownotification(context context) { intent intent = new intent(context, mainactivity.class); pendingintent pi = pendingintent.getactivity(context, 0, intent, 1); notificationcompat.builder mbuilder = new notificationcompat.builder(context) .setsmallicon(r.drawable.ic_launcher) .setcontenttitle("drawing!") .setcontenttext("the new drawing has been updated! check new numbers!") .setautocancel(true); mbuilder.setcontentintent(pi); mbuilder.setdefaults(notification.default_sound); //mbuilder.setautocancel(true); notificationmanager mnotificationmanager = (notificationmanager) context.getsystemservice(context.notification_service); mnotificationmanager.notify(0, mbuilder.build()); }
it goes off @ appropriate time (9:48 on wednesday testing purposes) when notification clicked on, appears again @ start of app. disappear second reemerges. though time when clicked on. there better way of doing or missing something? help.
Comments
Post a Comment