小编Yel*_*oud的帖子

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

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

表现:

<uses-permission android:name="com.android.launcher.action.INSTALL_SHORTCUT"/>
Run Code Online (Sandbox Code Playgroud)

类:

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);
Run Code Online (Sandbox Code Playgroud)

我需要在应用程序图标上显示计数器,只要有任何传入消息来到我的应用程序,如gmail应用程序 那么如何在android中动态获取应用程序图标和设置图标???

android

7
推荐指数
1
解决办法
4728
查看次数

标签 统计

android ×1