作者热门文章
- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我试过下面的代码来动态更改应用程序图标,但没有用。
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/
我是一名优秀的程序员,十分优秀!