android - How to increase the count badge when push notification recevied and app is open? -


hi in application have show unread push notifications count. when user in app on case when push received have update action bar item count in app.

here code:

public class basefragment extends fragment{      public static final string tag = "basefragment";     private customtextview mtxttitle;     public static textview mreadcount;     private relativelayout munreadcount;      @override     public void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);     }      @override     public view oncreateview(layoutinflater inflater,             viewgroup container, bundle savedinstancestate) {         view customactionbar = inflater.inflate(r.layout.custom_action_home, null);          ((mainactivity) getactivity()).getsupportactionbar().setcustomview(customactionbar);         getactionbarviewids(customactionbar);          return super.oncreateview(inflater, container, savedinstancestate);     }      private void getactionbarviewids(view view) {         mtxttitle = (customtextview) view.findviewbyid(r.id.txt_title);         mreadcount = (textview) view.findviewbyid(r.id.read_count);         mreadcount.settext("" + utility.getsharedprefintdata(getactivity(), constants.pref_key_notification_count));         munreadcount = (relativelayout) view.findviewbyid(r.id.unread_count);         munreadcount.setonclicklistener(new onclicklistener() {              @override             public void onclick(view v) {                 utility.navigatefragment(new notificationfragment(),                         notificationfragment.tag, null, getactivity());                 utility.setsharedprefintdata(getactivity(), constants.pref_key_notification_count, 0);             }         });     } 

all app extends basefragment. showing custom action bar in total app.

here have update count when push received.

there service handles push notifications far know there method called onmessage() overrice method whatever want


Comments