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

vivo新款手机需要添加权限才可以 #366

Open Zachary46 opened 3 years ago

Zachary46 commented 3 years ago

具体实现

a. 添加权限:

b. 应用在需要显示桌面角标的场景,通过广播将信息发送给vivoLauncher:

广播参数:

action:launcher.action.CHANGE_APPLICATION_NOTIFICATION_NUM

packageName:应用包名

className:主类名

notificationNum:未读消息数目

简单示例:

Intent intent = new Intent();

int missedCalls = 10;

intent.setAction("launcher.action.CHANGE_APPLICATION_NOTIFICATION_NUM");

intent.putExtra("packageName", "com.android.xxxx");

intent.putExtra("className", "com.android.xxxx.Mainxxxx");

intent.putExtra("notificationNum", missedCalls);

intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);

sendBroadcast(intent);

注意:

在8.0上,还需要给Intent加上下面的flag

Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND

ousq commented 3 years ago

launcher.action.CHANGE_APPLICATION_NOTIFICATION_NUM

as 这个打不出来 FLAG_RECEIVER_INCLUDE_BACKGROUND

yfdyh000 commented 3 years ago

launcher.action.CHANGE_APPLICATION_NOTIFICATION_NUM

as 这个打不出来 FLAG_RECEIVER_INCLUDE_BACKGROUND

368 试一下。