5

我有一个正在运行的应用程序,但我想添加与最近的应用程序窗口相关联的应用程序图标的替代版本。最近的应用程序窗口将使用另一个图标,而不是出现在主屏幕上的图标。

4

2 回答 2

9

可以做到这一点的方法是使用setTaskDescription(...)Activity 类中的新方法。它可用于设置任务的标题和任务的图标以显示在最近的应用程序屏幕中。这使用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类文档以及有关使用该类的文章。

于 2015-01-23T00:02:44.320 回答
3

在您的清单中:

android:logo="@mipmap/ic_launcher_round"

我不确定为什么这和icon和之间有区别,roundIcon但这对我有用。

于 2019-12-04T22:01:33.233 回答