Android为最近的应用使用不同的图标 [英] Android use a different icon for recent apps
问题描述
我有一个正在运行的应用程序,但我想添加与最近的应用程序窗口关联的应用程序图标的备用版本。最近的应用程序窗口将使用另一个,而不是主屏幕上显示的图标。
I have a working app but I want to add an alternate version of the app's icon that would be associated with the recent apps window. Instead of the icon that appears on the homescreen, the recent apps window would use the other one.
推荐答案
这可能是完成是在Activity类中使用新的 setTaskDescription(...)
方法。它可用于设置任务的标题和要在最近的应用程序屏幕中显示的任务的图标。这使用 ActivityManager.TaskDescription
类来设置这些值。请参阅下面的示例。请注意,所有此代码都属于您要修改其任务描述的活动。
The way this can be done is using the new setTaskDescription(...)
method in the Activity class. It can be used to set the title of the task and the icon of the task to display in the recent apps screen. This uses the ActivityManager.TaskDescription
class to set these values. See an example below. Note that all this code belongs in the activity whose task description you wish to modify.
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 类文档以及本文。
这篇关于Android为最近的应用使用不同的图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!