他们每个季节都会发布更新。 每个更新在res/drawable文件夹中都有一个新的定制图标。
此外,您可以声明不同的启动事件,然后使该启动事件的图标不同。
private void setIcon(int res_drawable)
{
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.N_MR1) {
Intent shortcutIntent = new Intent(getApplicationContext(), MainActivity.class);
shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
shortcutIntent.setAction(Intent.ACTION_MAIN);
ShortcutInfoCompat shortcut = new ShortcutInfoCompat.Builder(getContext(), "shortcut")
.setShortLabel(getResources().getString(R.string.app_name))
.setIcon(IconCompat.createWithResource(getApplicationContext(), res_drawable))
.setIntent(shortcutIntent)
.build();
ShortcutManagerCompat.requestPinShortcut(getApplicationContext(), shortcut, null);
}
else {
Intent i= new Intent(Intent.ACTION_MAIN);
i.addCategory(Intent.CATEGORY_LAUNCHER);
Intent intent = new Intent();
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, i);
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME,
context.getResources().getString(R.string.app_name));
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
Intent.ShortcutIconResource.fromContext(context, res_drawable));
intent.setAction(Intent.ACTION_CREATE_SHORTCUT);
context.sendBroadcast(intent);
}
}
如果你看代码,似乎是在启动时创建了一个快捷图标。
我找不到更好的方法,除了通过快捷方式或使用Activity别名来设置它。
另一种方法是手动编辑Google Play上的图标,但我不确定它是否只对安装生效还是只对PlayStore生效。
似乎大多数公司每个季节都会推出更新 - 圣诞版、复活节版等等...