以下是一个示例,演示如何在Android应用程序中更改最近应用程序的背景。
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription("Your App Name");
taskDescription.setBackgroundColor(ContextCompat.getColor(this, R.color.your_color));
setTaskDescription(taskDescription);
}
请注意,这段代码将只在Android 10(API级别29)及更高版本上起作用。在较早的版本中,您可以使用以下代码:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription("Your App Name", null, ContextCompat.getColor(this, R.color.your_color));
setTaskDescription(taskDescription);
}
#FF0000
请替换#FF0000为您想要的颜色代码。
通过执行上述步骤,您可以更改您的Android应用程序的最近应用程序背景颜色。请注意,这只会影响最近应用程序列表中的应用程序快照背景,而不会更改应用程序本身的背景。