gpt4 book ai didi

android - 如何在android中动态更改APP图标

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:05:53 25 4
gpt4 key购买 nike

我试过下面的代码来动态更改应用程序图标,但没有用。

list :

<uses-permission android:name="com.android.launcher.action.INSTALL_SHORTCUT"/>

类:

Intent myLauncherIntent = new Intent();
myLauncherIntent.setClassName("your.package.name", "YourLauncherActivityName");
myLauncherIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

Intent intent = new Intent();
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, myLauncherIntent);
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "Application Name");
intent.putExtra
(
Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
Intent.ShortcutIconResource.fromContext
(
getApplicationContext(),
R.drawable.app_icon
)
);
intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");

getApplicationContext().sendBroadcast(intent);

每当收到任何传入消息时,我都需要在应用程序图标上显示计数器我的应用程序像 gmail 应用程序。又怎样我可以在 Android 中动态获取应用程序图标和设置图标吗???

最佳答案

您不能动态修改应用程序图标。 Gmail 不会动态修改应用程序图标。

主屏幕——作为实际显示这些内容的应用——可以选择将徽章应用于某些应用图标。您还可以创建一个看起来像带徽章图标的应用程序小部件。

关于android - 如何在android中动态更改APP图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17146728/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com