Open Jule- opened 6 years ago
It seems to be the same as my problem.
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.
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.
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:
Any insight on this one?