【发布时间】:2015-03-05 22:44:55
【问题描述】:
我有一个正在运行的应用程序,但我想添加与最近使用的应用程序窗口相关联的应用程序图标的替代版本。最近的应用程序窗口将使用另一个图标,而不是出现在主屏幕上的图标。
【问题讨论】:
-
重启设备为我解决了这个问题
标签: android icons android-recents
我有一个正在运行的应用程序,但我想添加与最近使用的应用程序窗口相关联的应用程序图标的替代版本。最近的应用程序窗口将使用另一个图标,而不是出现在主屏幕上的图标。
【问题讨论】:
标签: android icons android-recents
可以做到这一点的方法是在 Activity 类中使用新的setTaskDescription(...) 方法。它可用于设置任务的标题和任务的图标以显示在最近的应用程序屏幕中。这使用ActivityManager.TaskDescription 类来设置这些值。请参阅下面的示例。请注意,所有这些代码都属于您要修改其任务描述的活动。
Bitmap recentsIcon; // Initialize this to whatever you want
String title; // You can either set the title to whatever you want or just use null and it will default to your app/activity name
int color; // Set the color you want to set the title to, it's a good idea to use the colorPrimary attribute
ActivityManager.TaskDescription description = ActivityManager.TaskDescription(title, recentsIcon, color);
this.setTaskDescription(description);
查看ActivityManager.TaskDescription 类文档以及this article 使用该类。
【讨论】:
在您的清单中:
android:logo="@mipmap/ic_launcher_round"
我不确定为什么这与 icon 和 roundIcon 之间存在差异,但这对我有用。
【讨论】: