B4A Library ShortcutBadger V1.7

DonManfred

Expert
Licensed User
This is a wrap for this Github project

The ShortcutBadger makes your Android App show the count of unread messages (or whatever count you want to show) as a badge on your App shortcut on your "Desktop"

ShortCutBadger
Author:
DonManfred (wrapper)
Version: 1.5
  • ShortcutBadger
    Methods:
    • Initialize
    • IsInitialized As Boolean
    • applyCount (badgeCount As Int) As Boolean
      Tries to update the notification count
      context: Caller context
      badgeCount: Desired badge count
      Return type: @return:true in case of success, false otherwise
    • applyCountOrThrow (badgeCount As Int)
      Tries to update the notification count, throw a {@link ShortcutBadgeException} if it fails
      context: Caller context
      badgeCount: Desired badge count
    • removeCount As Boolean
      Tries to remove the notification count
      context: Caller context
      Return type: @return:true in case of success, false otherwise
    • removeCountOrThrow
      Tries to remove the notification count, throw a {@link ShortcutBadgeException} if it fails
      context: Caller context

Please note that the Example here is prepared to be used on Samsung Devices as it contains the Permissions needed on Samsung Device.

Note the AppPermission commands in manifest editor:

For Samsung:
B4X:
AddPermission(com.sec.android.provider.badge.permission.READ)
AddPermission(com.sec.android.provider.badge.permission.WRITE)
For HTC:
B4X:
AddPermission(com.htc.launcher.permission.READ_SETTINGS)
AddPermission(com.htc.launcher.permission.UPDATE_SHORTCUT)
For SONY:
B4X:
AddPermission(com.sonyericsson.home.permission.BROADCAST_BADGE)
For APEX:
B4X:
AddPermission(com.anddoes.launcher.permission.UPDATE_COUNT)
For Solid:

B4X:
AddPermission(com.majeur.launcher.permission.UPDATE_BADGE)
Code used

B4X:
Sub Globals
  'These global variables will be redeclared each time the activity is created.
  'These variables can only be accessed from this module.
  Dim badge As ShortcutBadger
End Sub

Sub Activity_Create(FirstTime As Boolean)
  'Do not forget to load the layout file created with the visual designer. For example:
  'Activity.LoadLayout("Layout1")
  badge.Initialize()

  badge.applyCount(17)
End Sub
Please Note the count of 17 to find the icon in the Screenshot

The Screenshot here is from the Nova Launcher running on my Samsung S6 EDGE


If you want to donate for my work building the wrapper you can do it here:
 

Attachments

Last edited:

somed3v3loper

Well-Known Member
Licensed User
As usual a great library from a great wrapper :)

If we want it to work on all launchers that support count , we should add all these lines to manifest .
Am I right ?
 

Daniel-White

Active Member
Licensed User
Nice job, and very friendly to use, DonManfred, I did a test in Lg-G2 with android ver 4.4.2 work smoothly, however in my Samsung Pocket Neo with Android ver 5.0.2 does not show the count n#17. My understanding, I don't know it is 100% true, I had been reading about it in Internet, some phone brands do not allow that feature.

I had been asking one month ago about how we can do this feature. thanks for share it. :D
 

Bel

Active Member
Licensed User
Perfect library.
It dont working in Huawe phone,what i am doing?
 

MarcoRome

Expert
Licensed User
Perfect library.
It dont working in Huawe phone,what i am doing?
Try this:
B4X:
AddPermission(com.huawei.launcher3.permission.READ_SETTINGS)
AddPermission(com.huawei.launcher3.permission.WRITE_SETTINGS)
AddPermission(com.huawei.launcher2.permission.READ_SETTINGS)
AddPermission(com.huawei.launcher2.permission.READ_SETTINGS)
AddPermission(com.huawei.android.launcher.permission.WRITE_SETTINGS)
AddPermission(com.huawei.android.launcher.permission.READ_SETTINGS)
 

Bel

Active Member
Licensed User
Try this:
B4X:
AddPermission(com.huawei.launcher3.permission.READ_SETTINGS)
AddPermission(com.huawei.launcher3.permission.WRITE_SETTINGS)
AddPermission(com.huawei.launcher2.permission.READ_SETTINGS)
AddPermission(com.huawei.launcher2.permission.READ_SETTINGS)
AddPermission(com.huawei.android.launcher.permission.WRITE_SETTINGS)
AddPermission(com.huawei.android.launcher.permission.READ_SETTINGS)
Thanks i try it
 

DonManfred

Expert
Licensed User
The version 1.1.2 say that theres a support for com.miui.mihome2
I´ve updated the lib to V1.1 which reflects the newest Github release. See Download in Post #1

But i cant help on setting it up on your device. I did not found info about it... Maybe you need to ask the githubproject-author how to do for miui...
 

biometrics

Active Member
Licensed User
I needed the following manifest entry for it to work on my Sony Z3:

B4X:
AddPermission(com.sonymobile.home.permission.PROVIDER_INSERT_BADGE)
This is my current manifest entries, if you have more please share them here:

B4X:
'Samsung
AddPermission(com.sec.android.provider.badge.permission.READ)
AddPermission(com.sec.android.provider.badge.permission.WRITE)
'HTC
AddPermission(com.htc.launcher.permission.READ_SETTINGS)
AddPermission(com.htc.launcher.permission.UPDATE_SHORTCUT)
'Sony
AddPermission(com.sonyericsson.home.permission.BROADCAST_BADGE)
AddPermission(com.sonymobile.home.permission.PROVIDER_INSERT_BADGE)
'Apex
AddPermission(com.anddoes.launcher.permission.UPDATE_COUNT)
'Solid
AddPermission(com.majeur.launcher.permission.UPDATE_BADGE)
'Huawei
AddPermission(com.huawei.launcher3.permission.READ_SETTINGS)
AddPermission(com.huawei.launcher3.permission.WRITE_SETTINGS)
AddPermission(com.huawei.launcher2.permission.READ_SETTINGS)
AddPermission(com.huawei.launcher2.permission.READ_SETTINGS)
AddPermission(com.huawei.android.launcher.permission.CHANGE_BADGE)
AddPermission(com.huawei.android.launcher.permission.WRITE_SETTINGS)
AddPermission(com.huawei.android.launcher.permission.READ_SETTINGS)
'Zuk
AddPermission(android.permission.READ_APP_BADGE)
'Oppo
AddPermission(com.oppo.launcher.permission.READ_SETTINGS)
AddPermission(com.oppo.launcher.permission.WRITE_SETTINGS)
'EvMe
AddPermission(me.everything.badger.permission.BADGE_COUNT_READ)
AddPermission(me.everything.badger.permission.BADGE_COUNT_WRITE)
Thanks DonManfred.
 
Last edited:
Top