java - Android: Notification is displaying more than once -


i need show notification @ 3 everyday. working fine , sending notification around 3 am. when test in phone notification comes immediately. read if time crossed show notification. fine this. issue: when click notification opens activity correctly. after few seconds loading notification. if click again closing notification , creating new 1 after few seconds.

here code: 1. in activity oncreate()

calendar calendar = calendar.getinstance(); // calendar.set(calendar.month, 10); // calendar.set(calendar.year, 2014); // calendar.set(calendar.day_of_month, 13); calendar.set(calendar.hour_of_day, 3); calendar.set(calendar.minute, 0); calendar.set(calendar.second, 0); calendar.set(calendar.am_pm, calendar.am);  intent myintent = new intent(litcalactivity.this, myreceiver.class); pendingintent = pendingintent.getbroadcast(litcalactivity.this, 0, myintent, pendingintent.flag_one_shot); alarmmanager alarmmanager = (alarmmanager) getsystemservice(alarm_service); alarmmanager.setinexactrepeating(alarmmanager.rtc, calendar.gettimeinmillis(), alarmmanager.interval_day, pendingintent); 

in service class

public void onstart(intent intent, int startid) {         super.onstart(intent, startid);          // code notification setup         intent litrcalintent = new intent(this, litcalactivity.class);         bundle bundle = new bundle();         bundle.putstring("fromnotify", "yes");         litrcalintent.putextras(bundle);         pendingintent pintent = pendingintent.getactivity(this, 0,                 litrcalintent, pendingintent.flag_update_current);          simpledateformat format = new simpledateformat("mmmm dd yyyy");         string today = format.format(currentdate);         string todaydetails = getlitcaldetails();          notification notification = new notification.builder(this)                 .setcontenttitle("liturgical calendar " + today)                 .setcontenttext(todaydetails)                 .setsmallicon(r.drawable.ic_launcher)                 .setcontentintent(pintent)                 .setautocancel(true)                 .setongoing(false)                 .addaction(r.drawable.ic_launcher, "more...", pintent).build();          notificationmanager notificationmanager = (notificationmanager) getsystemservice(notification_service);          notificationmanager.notify(0, notification);       } 


Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -