Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Badger for every android device

Tags:

android

hello I have android application and I need to add badger to app launcher I searched on the internet and found this library

compile 'me.leolin:ShortcutBadger:1.1.4@aar'

is working but not for all device I tried at Samsung and HTC and its working but on Hawaii or sony not working how I can make this work for every Android device?

this is my code

 int badgeCount = 0;
            try {
                badgeCount = Integer.parseInt(bundle.getString("badge"));
            } catch (NumberFormatException e) {
                e.printStackTrace();
            }
            try {
                ShortcutBadger.applyCount(getApplicationContext(), badgeCount);
            } catch (Exception e) {
                e.printStackTrace();
                Log.d("BADGE","BADGE");
            }

then I tried to add permission to manifest like this, also not working

  <!--for Samsung-->
    <uses-permission android:name="com.sec.android.provider.badge.permission.READ"/>
    <uses-permission android:name="com.sec.android.provider.badge.permission.WRITE"/>

    <!--for htc-->
    <uses-permission android:name="com.htc.launcher.permission.READ_SETTINGS"/>
    <uses-permission android:name="com.htc.launcher.permission.UPDATE_SHORTCUT"/>

    <!--for sony-->
    <uses-permission android:name="com.sonyericsson.home.permission.BROADCAST_BADGE"/>
    <uses-permission android:name="com.sonymobile.home.permission.PROVIDER_INSERT_BADGE"/>

    <!--for apex-->
    <uses-permission android:name="com.anddoes.launcher.permission.UPDATE_COUNT"/>

    <!--for solid-->
    <uses-permission android:name="com.majeur.launcher.permission.UPDATE_BADGE"/>

    <!--for huawei-->
    <uses-permission android:name="com.huawei.android.launcher.permission.CHANGE_BADGE"/>
    <uses-permission android:name="com.huawei.android.launcher.permission.READ_SETTINGS"/>
    <uses-permission android:name="com.huawei.android.launcher.permission.WRITE_SETTINGS"/>

    <!--for ZUK-->
    <uses-permission android:name="android.permission.READ_APP_BADGE"/>

    <!--for OPPO-->
    <uses-permission android:name="com.oppo.launcher.permission.READ_SETTINGS"/>
    <uses-permission android:name="com.oppo.launcher.permission.WRITE_SETTINGS"/>

    <!--for EvMe-->
    <uses-permission android:name="me.everything.badger.permission.BADGE_COUNT_READ"/>
    <uses-permission android:name="me.everything.badger.permission.BADGE_COUNT_WRITE"/>
like image 378
Moayed Alayaseh Avatar asked May 27 '26 14:05

Moayed Alayaseh


1 Answers

how i can make this work for every android device ?

You can't.

The decision of how to display things on the home screen is up to the developers of the home screen, not you. There are hundreds of different home screen implementations for Android, both pre-installed and user-installed. None have to offer any sort of API for app developers to set a badge on a launcher icon.

Some will have such an API and will document it. Some will have such an API for internal use, and developers of libraries like the one that you are trying to use may try to help you use those internal APIs. But many home screens will not have any sort of API for this.

Your primary choices are:

  1. Stop trying to deal with launcher icon badges entirely.

  2. Settle for what your library offers you.

  3. Write your own home screen and attempt to force users to use your home screen, just so that you can have launcher icon badges.

like image 140
CommonsWare Avatar answered May 30 '26 02:05

CommonsWare