Search code examples
androidandroid-notificationsandroid-notification-bar

How to add Notification Counter Android


How do I add a notification Counter in Android Application, Similar to that of Facebook's? I have tried searching but I have not found anything that can help. I do not want counter baloon on the launcher icon. Instead, I want it inside my application on notification icon and friends icon.

My Search Includes:

All of the other examples including these are showing notification balloon over the launcher icon. I do not want notification balloon over the launcher icon. Instead, I want the notification balloon inside my application over notification icon similar to Facebook's one. How can I implement it? Any suggestions, steps, or guides would be appreciated.

enter image description here


Solution

  • This can be achieved with this library. https://github.com/jgilfelt/android-viewbadger

    Include library in your project and add below code for your view.

    View target = findViewById(R.id.target_view);
    BadgeView badge = new BadgeView(this, target);
    badge.setText("1");
    badge.show();