leolin310148 / ShortcutBadger

An Android library supports badge notification like iOS in Samsung, LG, Sony and HTC launchers.
Other
7.35k stars 1.34k forks source link

Not working on Asus Zenfone 5 - ZenUI #315

Open Jule- opened 6 years ago

Jule- commented 6 years ago

ShortcutBadger

version: v1.1.22

Smartphone

model: ASUS_X00QD android: Android 8.0.0

ZenUI

package: com.asus.launcher version: 5.0.1.61_180824 version code: 1550001305


No badge is visible. Tested with SampleApp.

When debugging:

unable to resolve intent: Intent { act=me.leolin.shortcutbadger.BADGE_COUNT_UPDATE flg=0x8 (has extras) }
unable to resolve intent: Intent { act=android.intent.action.BADGE_COUNT_UPDATE flg=0x8 (has extras) }

Any insight on this one?

guhyeon commented 6 years ago

It seems to be the same as my problem.

https://github.com/leolin310148/ShortcutBadger/issues/314

Jule- commented 6 years ago

Hey, thanks for pointing me this but unfortunately that does not work for me... 😞 Indeed it hits the resolveInfos.size() == 0 test but even if I force context.sendBroadcast(intent) like you suggests it does not set badge on launcher icon.

Jule- commented 6 years ago

By the way @guhyeon you are right there is some issues depending on the broadcast resolver result since it can fail to find one while an adb shell dumpsys activity broadcasts shows that there is valid receivers.

For my purpose, I have this code that throws:

final String INTENT_ACTION = "android.intent.action.BADGE_COUNT_UPDATE";
final String INTENT_EXTRA_BADGE_COUNT = "badge_count";
final String INTENT_EXTRA_PACKAGENAME = "badge_count_package_name";
final String INTENT_EXTRA_ACTIVITY_NAME = "badge_count_class_name";

Intent intent = new Intent(INTENT_ACTION);
intent.putExtra(INTENT_EXTRA_BADGE_COUNT, badgeCount);
intent.putExtra(INTENT_EXTRA_PACKAGENAME, componentName.getPackageName());
intent.putExtra(INTENT_EXTRA_ACTIVITY_NAME, componentName.getClassName());
intent.putExtra("badge_vip_count", 0);

List<ResolveInfo> resolveInfos = resolveBroadcast(context, intent);
if (resolveInfos.size() == 0) {
    throw new ShortcutBadgeException("unable to resolve intent: " + intent.toString()); // <== throws here
}

while

$ adb shell dumpsys activity broadcasts
...
  * ReceiverList{###### #### com.asus.launcher/#####/u0 remote:#######}
    app=####:com.asus.launcher/##### pid=#### uid=##### user=0
    Filter #0: BroadcastFilter{#######}
      Action: "android.intent.action.BADGE_COUNT_UPDATE"
      Action: "com.sonyericsson.home.action.UPDATE_BADGE"
...

That is how I understood that ZenUI handle Sony like badge update and I have to send intent blindly if I want it to work.