【问题标题】:Android use a different icon for recent appsAndroid 为最近的应用程序使用不同的图标
【发布时间】:2015-03-05 22:44:55
【问题描述】:

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

【问题讨论】:

  • 重启设备为我解决了这个问题

标签: android icons android-recents


【解决方案1】:

可以做到这一点的方法是在 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 使用该类。

【讨论】:

    【解决方案2】:

    在您的清单中:

    android:logo="@mipmap/ic_launcher_round"
    

    我不确定为什么这与 iconroundIcon 之间存在差异,但这对我有用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-03-06
      • 2020-12-03
      • 1970-01-01
      • 2019-08-15
      • 2013-05-08
      • 2018-01-28
      • 1970-01-01
      • 2021-10-14
      相关资源
      最近更新 更多