How Do I Get the Red Number on My App Icon Android?

Android, Android Apps

Do you ever wonder how some apps on your Android device have a red number displayed on their app icon? If you’re curious about adding this feature to your own app, you’ve come to the right place! In this tutorial, we’ll walk through the steps to get the red number notification on your app icon in Android.

Step 1: Implementing the Notification Badge Library

If you want to add a red number notification badge to your app icon, you’ll need to use a library that provides this functionality. One popular library that can help you achieve this is the Notification Badge library. To implement it in your project, follow these steps:

  • Step 1.1: Open your build.gradle file in your Android project.
  • Step 1.2: Add the following line of code inside the dependencies block:

dependencies {
// Other dependencies..
implementation ‘me.leolin:ShortcutBadger:1.1.22@aar’

This will add the Notification Badge library to your project.

Step 2: Setting Up Permissions

In order for the Notification Badge library to work properly, you’ll need to make sure that you have the necessary permissions declared in your AndroidManifest.xml file. Follow these steps:

  • Step 2.1: Open your AndroidManifest.xml file.
  • Step 2.2: Add the following lines of code inside the manifest tag:



These permissions are required to update the app icon badge on the launcher.

Step 3: Implementing the Badge Update

Now that you have the Notification Badge library added to your project and the necessary permissions set up, you can start implementing the badge update feature. Here’s how:

  • Step 3.1: Open the Java file where you want to implement the badge update.
  • Step 3.2: Import the necessary classes:

import me.leolin.shortcutbadger.ShortcutBadger;

  • Step 3.3: Use the following code snippet to update the badge count:

int badgeCount = 5; // Set your desired number here
ShortcutBadger.applyCount(context, badgeCount);

This code snippet sets the badge count to 5, but you can replace it with any desired number.

Step 4: Testing and Troubleshooting

You’re almost done! Now it’s time to test your implementation and make sure everything works as expected. If you encounter any issues, here are some troubleshooting tips:

  • If the badge doesn’t appear on your app icon:
    • Make sure you have followed all of the previous steps correctly.
    • Check if your launcher supports notification badges. Some launchers don’t have this feature built-in.
  • If the badge count is not updating:
    • Double-check your code implementation.
    • Verify that you have the necessary permissions set up correctly.

Congratulations! You have successfully implemented the red number notification badge on your app icon in Android.

Now your users will be able to see important updates at a glance. Keep in mind that different devices and launchers may have slightly different behaviors, so always test thoroughly on various platforms to ensure consistent performance.

Remember to experiment with different badge counts and explore other features provided by the Notification Badge library to further enhance your app’s user experience. Happy coding!