gpt4 book ai didi

Android 为最近的应用程序使用不同的图标

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:14:17 26 4
gpt4 key购买 nike

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

最佳答案

完成此操作的方法是在 Activity 类中使​​用新的 setTaskDescription(...) 方法。它可用于设置任务的标题和任务的图标以显示在最近的应用程序屏幕中。这使用 ActivityManager.TaskDescription 类来设置这些值。请参见下面的示例。请注意,所有这些代码都属于您要修改其任务描述的 Activity 。

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关于使用类(class)。

关于Android 为最近的应用程序使用不同的图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27829625/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com