繁体   English   中英

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

[英]How to change APP icon dynamically in android

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

表现:

<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不会动态修改应用图标。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM