How do I show the number of alarms on Android?

Asked 2 years ago, Updated 2 years ago, 56 views

1

Like the image above, text messaging app on AndroidIf you look at Kakao, the number of alarms on iKON is shown in a red circle. I also want to put it up on the icon of my app, what should I do?

android

2022-09-21 19:06

1 Answers

int badgeCount = 3;
        Intent intent = new Intent("android.intent.action.BADGE_COUNT_UPDATE");
        intent.putExtra("badge_count", badgeCount);
        // Package name of the application that appears in the main menu
        intent.putExtra("badge_count_package_name", getComponentName().getPackageName());
        // The class name of the application that appears in the main menu
        intent.putExtra("badge_count_class_name", getComponentName().getClassName());
        sendBroadcast(intent);

If the bad count is 0, there is no indication on the icon, and if it is more than 1, there will be indication on the icon.


2022-09-21 19:06

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.