Search code examples
androidwindowswitching

How do I change the color of this bar when switching apps?


With the addition of Lollipop, it appears you can now change the color of this window when changing apps. I don't know what it is called and therefore can't find any info on it but if you look at the image you can see that the Keep app is now yellow.

How do I go about changing this color?

Here is a link to the image, it won't let me attach it since I'm new

Thanks


Solution

  • You can use setTaskDescription() to achieve this:

    setTaskDescription(new ActivityManager.TaskDescription(label, icon, color));
    

    For android documentation:

    Sets information describing the task with this activity for presentation inside the Recents System UI. When getRecentTasks(int, int) is called, the activities of each task are traversed in order from the topmost activity to the bottommost. The traversal continues for each property until a suitable value is found. For each task the taskDescription will be returned in ActivityManager.TaskDescription.

    Parameters taskDescription The TaskDescription properties that describe the task with this activity

    https://developer.android.com/reference/android/app/Activity.html#setTaskDescription(android.app.ActivityManager.TaskDescription)