Android Notifications Cancel -


i have been working on android notifications , works fine. problem have when cancel notifications manager.cancel() or manager.cancel(id) , notification arrives, canceled notifications shown yet want them canceled forever, please help. below code.

 private void sendnotification(string msg) {           intent intent = null;         if(request_id != null)         {             intent = new intent(ctx, payapp.class)                     .putextra("fragment", "transactions")                     .putextra("request_id", request_id)                     .putextra("notificationid", notification_id);         }         else         {             intent = new intent(ctx, payapp.class).putextra("fragment", "transactions");         }          intent.addflags(intent.flag_activity_clear_top);          mnotificationmanager = (notificationmanager)                 ctx.getsystemservice(context.notification_service);          pendingintent contentintent = pendingintent.getactivity(ctx, 0,                 intent, pendingintent.flag_one_shot);          counter = notificationcounter.incrementandget();         uri defaultsounduri = ringtonemanager.getdefaulturi(ringtonemanager.type_notification);         notificationcompat.builder mbuilder =                 new notificationcompat.builder(ctx)                         .setsmallicon(r.mipmap.ic_launcher)                         .setsound(defaultsounduri)                         .setautocancel(true).setnumber(counter)                         .setcontenttext(msg)                         .setpriority(notification.priority_max)                         .setcolor(contextcompat.getcolor(ctx, r.color.intel_blue_deeper))                         .setcontenttitle("xente agency");          notificationcompat.inboxstyle inboxstyle = new notificationcompat.inboxstyle(mbuilder);          inboxstyle.setbigcontenttitle("xente agency");         messagelist.add(msg);         for(string m : messagelist)        {            inboxstyle.addline(m);        }          mbuilder.setstyle(inboxstyle);         mbuilder.setcontentintent(contentintent);         mnotificationmanager.notify(notification_id, mbuilder.build());      } 

and cancel fragment opens on click

if(getarguments() != null)         {             request_id = getarguments().getstring("request_id");             notification_id = getarguments().getint("notificationid", 0);              if(notification_id == 1)             {                 notificationmanager manager = (notificationmanager)getactivity().getsystemservice(context.notification_service);                 //this not work                 //manager.cancel(notification_id)                 manager.cancelall();                 notification_id = 0;             }         } 

can try set flag_update_current flag instead of flag_one_shot flag?

pendingintent contentintent = pendingintent.getactivity(ctx, 0,                 intent, pendingintent.flag_update_current); 

Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -