An Android library supports badge notification like iOS in Samsung, LG, Sony and HTC launchers.

Related tags

UI/UX ShortcutBadger
Overview

ShortcutBadger: Maven Central

The ShortcutBadger makes your Android App show the count of unread messages as a badge on your App shortcut!

Supported launchers:

Sony


Samsung


LG


HTC


Xiaomi



ASUS


ADW


APEX


NOVA


Huawei


(Not Fully Support)

(1.1.7+)

ZUK



(1.1.10+)

OPPO


(Not Fully Support)

(1.1.10+)

EverythingMe


ZTE



(1.1.17+)

KISS



(1.1.18+)

LaunchTime


Yandex Launcher



(1.1.23+)
  • Nova launcher with TeslaUnread, Apex launcher, ADW Launcher provided by notz
  • Solid launcher provided by MajeurAndroid
  • KISS Launcher provided by alexander255

About Xiaomi devices

Xiaomi devices require extra setup with notifications, please read wiki.

IsBadgeWorking?

A tool for displaying your device, launcher & android version and testing whether ShortcutBadger works or not may be downloaded from

USAGE


1. Add mavenCentral to your build script.

    repositories {
        mavenCentral()
    }


2. Add dependencies for ShortcutBadger, it's available from maven now.

    dependencies {
        implementation "me.leolin:ShortcutBadger:1.1.22@aar"
    }


3. Add the codes below:

    int badgeCount = 1;
    ShortcutBadger.applyCount(context, badgeCount); //for 1.1.4+
    ShortcutBadger.with(getApplicationContext()).count(badgeCount); //for 1.1.3


4. If you want to remove the badge

    ShortcutBadger.removeCount(context); //for 1.1.4+
    ShortcutBadger.with(getApplicationContext()).remove();  //for 1.1.3

or

    ShortcutBadger.applyCount(context, 0); //for 1.1.4+
    ShortcutBadger.with(getApplicationContext()).count(0); //for 1.1.3




DEVELOP BY

Leo Lin - [email protected]

ABOUT Google Play Developer Term Violations

If you receive a message from Google containing something like this:

    REASON FOR WARNING: Violation of section 4.4 of the Developer Distribution Agreement.

please use version 1.1.0+!

CHANGE LOG

1.1.23:

  • Added Yandex Launcher support. Fixed issue with incorrect default launcher resolve

1.1.22:

1.1.20:

  • Renamed default broadcast action; added Android Oreo support.

1.1.19:

  • Fix multiple home package resolve issue.

1.1.18:

  • Add Kill Launcher Support

1.1.17:

  • Add ZTE Support

1.1.16:

  • Improve Sony Launcher support.

1.1.15:

  • Add EverythingLauncher Support.

1.1.14:

  • Fix for specific class of Samsung devices: with android 5, but without support of DefaultBadger
  • Remove Xiaomi from Badger and add Notification Support for Xiaomi devices.

1.1.13:

  • Fix XiaomiBadger (tested with RedMi Note4)

1.1.12:

  • Handling Samsung badger for old devices and new devices.
  • Try to support newer Xiaomi (Not tested.)
  • Try to support Vivo (Not tested.)

1.1.11:

  • Add OPPO Launcher Support

1.1.10:

  • Add ZUK Launcher Support

1.1.9:

  • Add SamsungBadger back for more Samsung devices support.

1.1.8:

  • Remove SolidBadger, now solid launcher will use default badger.

1.1.7:

  • Add Huawei launcher support.

1.1.6:

  • Add support for new Sony Launchers.

1.1.5:

  • applyCount will return if the Broadcast has been sent successfully.

1.1.4:

  • Changed ShortcutBadger.setBadge(context, badgeCount) to ShortcutBadger.applyCount(context, badgeCount);

1.1.3:

  • Deprecate SamsungBadger and LGBadger, those devices can use DefaultBadger.

1.1.2:

  • Add support for com.miui.mihome2

1.1.1:

  • Add DefaultBadger because some launchers use android.intent.action.BADGE_COUNT_UPDATE to update count.
  • Since the ShortcutBadgerException is helpless. So change api to set badge and never have to handle the exception again.

1.1.0:

  • Remove Android Launcher support due to Google Play Developer Term Violation since 4.4.

1.0.10:

  • Add Asus launcher support.

1.0.9:

  • Add Xiaomi launcher support.

LICENSE


    Copyright 2014 Leo Lin
    
    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at
    
        http://www.apache.org/licenses/LICENSE-2.0
    
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

Comments
  • unable to resolve intent: Intent { act=android.intent.action.BADGE_COUNT_UPDATE (has extras) }

    unable to resolve intent: Intent { act=android.intent.action.BADGE_COUNT_UPDATE (has extras) }

    i am trying to run this project. but i get this error: E/ShortcutBadger: Unable to execute badge:Unable to execute badge:unable to resolve intent: Intent { act=android.intent.action.BADGE_COUNT_UPDATE (has extras) }

    i have no idea what the problem. anyone can help me? thanks.

    opened by estysherman 21
  • Nexus 7 SecurityException

    Nexus 7 SecurityException

    I implemented the ShortcutBadger within my project and it is running perfectly on my Samsung Note 2 and Samsung Tab 4. I am running into an issue when running my code on a Google Nexus 7. I get the following:

    FATAL EXCEPTION: main java.lang.SecurityException: Permission Denial: writing com.android.launcher2.LauncherProvider uri content://com.android.launcher2.settings/favorites?notify=true from pid=4933, uid=10127 requires com.android.launcher.permission.WRITE_SETTINGS, or grantUriPermission() at android.os.Parcel.readException(Parcel.java:1465) at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:185) at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:137) at android.content.ContentProviderProxy.update(ContentProviderNative.java:560) at android.content.ContentResolver.update(ContentResolver.java:1316) at com.shortcutBadger.impl.AndroidHomeBadger.executeBadge(AndroidHomeBadger.java:37) at com.shortcutBadger.ShortcutBadger.setBadge(ShortcutBadger.java:74)

    I have the following in my Manifest File:

    <uses-permission android:name="com.android.launcher.permission.READ_SETTINGS" />
    <uses-permission android:name="com.android.launcher.permission.WRITE_SETTINGS" />
    <uses-permission android:name="com.sonyericsson.home.permission.BROADCAST_BADGE" />
    <uses-permission android:name="com.htc.launcher.permission.WRITE_SETTINGS" />
    <uses-permission android:name="com.htc.launcher.permission.READ_SETTINGS" />
    <uses-permission android:name="com.sec.android.provider.badge.permission.READ" />
    <uses-permission android:name="com.sec.android.provider.badge.permission.WRITE" />
    

    I have the correct permission, but something is still not happy. Any idea what could be causing this exception?

    opened by mikewalkerjr 12
  • XIAOMI device with miui 7 not work

    XIAOMI device with miui 7 not work

    I use XIMI 5s with MIUI 7.3 and set badger count ,but not show . I debug the code get error info

    field android.app.MiuiNotification.messageCount has type int, got java.lang.String in XiaomiHomeBadger class and code in

     Field field = miuiNotification.getClass().getDeclaredField("messageCount");
     field.setAccessible(true);
     field.set(miuiNotification, String.valueOf(badgeCount == 0 ? "" : badgeCount));
    
    opened by carl1990 9
  • in last version 1.1.8 samsung not workung, only in 1.1.4

    in last version 1.1.8 samsung not workung, only in 1.1.4

    me.leolin.shortcutbadger.ShortcutBadgeException: Unable to execute badge

    Caused by: me.leolin.shortcutbadger.ShortcutBadgeException: unable to resolve intent: Intent { act=android.intent.action.BADGE_COUNT_UPDATE (has extras) }

    opened by matanel11 9
  • not working on some of the devices I have

    not working on some of the devices I have

    I tested the library on some of the devices I have and it didn't work on any of them except only one Samsung device:

    | Model | Android Version | Working | | --- | --- | --- | | Asus Zenfone | 4.4.2 | Yes | | Samsung S7 | 6.0.1 | Yes | | Sony Xperia ZL | 5.1.1 | No | | Micromax Android One | 4.4.4 | No | | Motorola X | 6.0.1 | No | | OnePlus One | 5.1.1 | No | | Xiaomi Mi4i | 5.0.2 | No | | OnePlus X | 5.1.1 | No | | Lenovo K5 | 5.1.1 | No |

    opened by dhavaln 9
  • v1.1.21 is not working on Samsung Galaxy S9

    v1.1.21 is not working on Samsung Galaxy S9

    Hi Leo,

    Details: Model number: SM-G960F Android: 8.0.0 Samsung Experience Version: 9.0

    I tried with ShortcutBadger app and it is not working on S9, I tried to submit a working status by clicking on "No" button, But the app is showing "Something went wrong" toast.

    Any help would be appreciated!

    Cheers, Onkar

    opened by Onkarn92 7
  • SonyHomeBadger got an exception

    SonyHomeBadger got an exception

    I called "applyCount" from a background thread and got this exception. I used the "IsBadgeWorking?" app to try it, and then I got a crash.

    Exception: W/System.err: Caused by: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare() W/System.err: at android.os.Handler.(Handler.java:200) W/System.err: at android.os.Handler.(Handler.java:114) W/System.err: at android.content.AsyncQueryHandler.(AsyncQueryHandler.java:125) W/System.err: at me.leolin.shortcutbadger.impl.SonyHomeBadger$1.(SonyHomeBadger.java:78) W/System.err: at me.leolin.shortcutbadger.impl.SonyHomeBadger.executeBadgeByContentProvider(SonyHomeBadger.java:78) W/System.err: at me.leolin.shortcutbadger.impl.SonyHomeBadger.executeBadge(SonyHomeBadger.java:42)

    Crash: 02-21 09:52:29.051 20488-2674/me.leolin.isbadgeworking E/AndroidRuntime: FATAL EXCEPTION: AsyncQueryWorker Process: me.leolin.isbadgeworking, PID: 20488 java.lang.SecurityException: Missing permission to insert badges at android.os.Parcel.readException(Parcel.java:1629) at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:183) at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:135) at android.content.ContentProviderProxy.insert(ContentProviderNative.java:476) at android.content.ContentResolver.insert(ContentResolver.java:1244) at android.content.AsyncQueryHandler$WorkerHandler.handleMessage(AsyncQueryHandler.java:96) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:168) at android.os.HandlerThread.run(HandlerThread.java:61)

    screenshot_20170221-095920 1

    opened by AlanChiou 7
  • Crashing Samsung Galaxy S7 Edge

    Crashing Samsung Galaxy S7 Edge

    Trying to set a badge will crash for Samsung SM-G935T running Android 6.0.1. Confirmed in multiple devices.

    Fatal Exception: java.lang.SecurityException: Missing permission to insert badges at android.os.Parcel.readException(Parcel.java:1620) at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:183) at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:135) at android.content.ContentProviderProxy.insert(ContentProviderNative.java:476) at android.content.ContentResolver.insert(ContentResolver.java:1284) at android.content.AsyncQueryHandler$WorkerHandler.handleMessage(AsyncQueryHandler.java:96) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:158) at android.os.HandlerThread.run(HandlerThread.java:61)

    opened by pedronveloso 7
  • DefaultBadger not reliable on Samsung S4 (5.0.1)

    DefaultBadger not reliable on Samsung S4 (5.0.1)

    Using the recommended approach, I was able to set the badge icon for my app -- but only once. All future calls produced no effect and no exception. In my case, I initially set it to 10, and could not change it.

    Using your suggested code, the query showed that indeed the later calls did not affect the badge count (remained at 10, despite my calls to ShortcutBadger).

    However, if I manually instantiated your @Deprecated SamsungHomeBadger, and executed it, the badge did update as expected -- which is my current workaround.

    opened by igrayson 7
  • andriod 5.1.1 sumsung s6. - unable to resolve BADGE_COUNT_UPDATE

    andriod 5.1.1 sumsung s6. - unable to resolve BADGE_COUNT_UPDATE

    I am attempting to use ShortcutBadger to display count. When I call ShortcutBadger.applyCount(context, badgeCount);

    the logcat gives me: phonegap.helloworld D/ShortcutBadger: Finding badger phonegap.helloworld D/ShortcutBadger: Current badger:me.leolin.shortcutbadger.impl.DefaultBadger phonegap.helloworld E/ShortcutBadger: Unable to execute badge:Unable to execute badge:unable to resolve intent: Intent { act=android.intent.action.BADGE_COUNT_UPDATE (has extras) }

    andriod 5.1.1 sumsung s6. Get Current badger:me.leolin.shortcutbadger.impl.DefaultBadger On does anyone know why I am getting error Unable to execute badge let me know if more infor is required

    opened by devshisiyani 6
  • Does not work for LG Devices

    Does not work for LG Devices

    The badger does not seem to work on LG device. I tried checking with Nova & Apex launchers but still the badge count does not show up. Do i need to do anything else to make it work..?

    opened by sudhirconscious 6
  • How to show badge count in app icon for Oppo (Android)

    How to show badge count in app icon for Oppo (Android)

    Hi, i tried same as mention in GitHub, but count not show in app icon, below code i added in ondeviceready function in index.js file, i am developing android app in Cordova.

    int badgeCount = 1; ShortcutBadger.applyCount(context, badgeCount); //for 1.1.4+ ShortcutBadger.with(getApplicationContext()).count(badgeCount); //for 1.1.3

    Any reply much appreciated.

    opened by aravindforums1 0
  • Update Badge Number in Background Notification on Android

    Update Badge Number in Background Notification on Android

    I'm using ShortcutBadger latest version with cordova-plugin-fcm-with-dependecy-updated Notification badge update ok in ios by set badge number in payload but, in android cannot set badge in payload

    How to get this work using ShortcutBadger and FCM?

    opened by ash737 4
  • Samsung android 12 not Work

    Samsung android 12 not Work

    Notification badge not work in galaxy M 12 (android 12) I have targetSdkVersion = 28 in build.gradle but in config.xml targetSdkVersion equal to 30

    Cordova: 11.0.0 Cordova android: 8.1.0

    I have tested many android devices, all work fine but, Samsung Galaxy M 12 not work.

    Please help

    opened by ash737 6
  • Getting a build error - me.leolin:ShortcutBadger:1.1.22@aar

    Getting a build error - me.leolin:ShortcutBadger:1.1.22@aar

    After migrating our Ionic project from Capacitor 3 to Capacitor 4 (see migration guide) we're getting a build error when building for Android:

    Our app uses the cordova-plugin-badge plugin which in turn seems to rely pon ShortcutBadger?

    The error we get is:

    * Where:
    Script '/builds/rks/myApp/node_modules/cordova-plugin-badge/src/android/badge.gradle' line: 28
    
    * What went wrong:
    A problem occurred evaluating script.
    > Could not find method compile() for arguments [me.leolin:ShortcutBadger:1.1.22@aar] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
    

    Any ideas what we need to do?

    opened by richardkshergold 2
  • Android badge count not showing more than one digit like 10,11,...100

    Android badge count not showing more than one digit like 10,11,...100

    Hello friends,

    I have tried to implement this library and but facing one or two issues like not support all devices and if app badge count showing then not showing more than one digit it's stuck at 9 number.

    So after 9 badge count not showing number like 10,11,12.... it's just show one half second and then again showing 9 badge.

    Please help me.

    opened by AdilHypeteq 12
Owner
Leo Lin
Leo Lin
Floating Notification for Android app - Facebook ChatHeads Notification system

FloatingView (Application Demo on Play Store) DEPRECATED SEE FloatingView Floating View for Android app - Facebook ChatHeads Notification system This

Fernandez Anthony 530 Nov 17, 2022
This library offers a simple method to add a small badge icon to your ActionBar-MenuItem

Android-ActionItemBadge ActionItemBadge is a library which offers a simple and easy to use method to add a badge to your action item! Screenshots Incl

Mike Penz 1.3k Jan 1, 2023
[] A simple way to "badge" any given Android view at runtime without having to cater for it in layout

Android ViewBadger A simple way to "badge" any given Android view at runtime without having to cater for it in layout. Note: If your aim is to replica

Jeff Gilfelt 3k Nov 28, 2022
:octocat: Drawable of badge.

Badge Preview Integration Add the JitPack repository to your root build.gradle: repositories { maven { url "https://jitpack.io" } } Add the depend

nekocode 952 Dec 8, 2022
πŸͺ„ It's a library that helps you customize your notification bar

NotificationBarCustom ?? It's a library that helps you customize your notification bar Demo Contrast(white) Contrast(black) Transparent Setup Add it i

박상선 8 Sep 7, 2022
A new canvas drawing library for Android. Aims to be the Fabric.js for Android. Supports text, images, and hand/stylus drawing input. The library has a website and API docs, check it out

FabricView - A new canvas drawing library for Android. The library was born as part of a project in SD Hacks (www.sdhacks.io) on October 3rd. It is cu

Antwan Gaggi 1k Dec 13, 2022
Displays your screen time in a permanent notification.

Screen Time Displays your screen time in a permanent notification. By making screen time more prominent, you can get a better sense of how much of the

Markus Fisch 24 Nov 29, 2022
MIUINativeNotifyIcon - Fix the native notification bar icon function abandoned by the MIUI development team

MIUI εŽŸη”Ÿι€šηŸ₯ε›Ύζ ‡ Fix the native notification bar icon function abandoned by the MIUI

Fankesyooni 189 Jan 4, 2023
A realtime blurring overlay for Android (like iOS UIVisualEffectView)

RealtimeBlurView It's just a realtime blurring overlay like iOS UIVisualEffectView. Just put the view in the layout xml, no Java code is required. //

Tu Yimin 3k Jan 9, 2023
A Tinder-like Android library to create the swipe cards effect. You can swipe left or right to like or dislike the content.

Swipecards Travis master: A Tinder-like cards effect as of August 2014. You can swipe left or right to like or dislike the content. The library create

Dionysis Lorentzos 2.3k Dec 9, 2022
DailyTags - a flexible markdown library that supports custom tags and markups

The library parses a given markup into rich text for Jetpack Compose. DailyTags comes with Markdown and HTML support by default (please, see the supported features) and is very easy to extend to support custom markups.

Dmytro 134 Dec 25, 2022
Created a Tinder like Card Deck & Captain Train like Toolbar

TinderView Created A Simple and Beautiful Tinder like card deck & Captain Train like toolbar. This is heavily based on AndroidSwipeableCardStack, wenc

Aradh Pillai 328 Jun 18, 2022
A Material design Android pincode library. Supports Fingerprint.

LolliPin A Lollipop material design styled android pincode library (API 14+) To include in your project, add this to your build.gradle file: //Loll

Omada Health 1.6k Nov 25, 2022
Drag and drop to reorder items in a list, grid or board for Android. Based on RecyclerView. Also supports swiping items in a list.

DragListView DragListView can be used when you want to be able to re-order items in a list, grid or a board. It also supports horizontal swiping of it

Magnus Woxblom 658 Nov 30, 2022
Simple and powerful library to emulate iOS's "3D Touch" preview functionality on Android.

Android 3D Touch - PeekView iOS uses 3D Touch as a way to "peek" into full content, such as emails, pictures, web searches, etc. While they have dedic

Luke Klinker 502 Dec 29, 2022
A Jetpack Compose library with blur, pixelate, and other effects to keep your designer happy. Inspired by iOS UIVisualEffectView.

A Jetpack Compose library with blur, pixelate, and other effects to keep your designer happy. Inspired by iOS UIVisualEffectView.

ζΈ…θŒΆ 67 Dec 30, 2022
ios UISegmentedControl for android

android-segmented-control Android-Segmented is a custom view for Android which is based on RadioGroup and RadioButton widget. This implementation is i

Kaopiz Software Co., Ltd. 1.9k Dec 12, 2022
ios UISegmentedControl for android

android-segmented-control Android-Segmented is a custom view for Android which is based on RadioGroup and RadioButton widget. This implementation is i

Kaopiz Software Co., Ltd. 1.9k Dec 12, 2022
iOS UIActionSheet for Android

ActionSheet This is like iOS UIActionSheet component, has iOS6 and iOS7 style, support custom style, background, button image, text color and spacing

ζ˜ŸδΈ€ 810 Nov 10, 2022