0

I would like to change the colors and the icon of my Window Bar when my app apears in the Background Apps section (or whatever it is called).

Screenshot of my smartphone screen

For instance, Facebook's App shows a different icon in this screen, their ic_launcher icon is the white "f" on the blue background, the Instagram App changes the Window Bar background color from white to black, some apps change their Window Bar title color, and etc. I tried to search for this information but I am not sure how this feature is called or how to search for this, therefor I found no solutions.

Any help would be appreciated, thank you all in advance.

Gabriel Schneider
  • 605
  • 2
  • 6
  • 12

2 Answers2

2

If anyone comes across this same issue this is the solution to it:

The only way to style your App's apprearence in the Overview Screen (also referred to as the recents screen, recent task list, or recent apps) is to set a ActivityManager.TaskDescription. So this is how you do it:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {

        String label = getString(R.string.app_name);
        Bitmap icon = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_welcome_activity);
        int color = ResourcesCompat.getColor(getResources(), R.color.colorPrimary600, null);

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

    }

This must be done in your Activity onCreate() method or onResume(), some say it only workds with one or another, but for me it worked in both. You only have to insert this piece of code in your top Activity code, because by default, the TaskDescription is based on the activity at the base of the task’s activity stack, so other activities that pile on will not affect the styling, unless those activities have a TaskDescription explicitly set at run time.

Note that the text color can't be forced, it is auto generated (either white/black) based on your colorPrimary color. So an alternative to set the label color to white, that even Google appears to use, would be to set a darker colorPrimary, the 600, as the TaskDescription color, as I did in the above code. Lighter colors will have the text set to black.

Also make sure you surround the setTaskDescription(taskDesc) with a SDK version check, since this feature were only introduced on Lollipop.

A deeper explanation to this solution can be found here. Hope this helps.

Gabriel Schneider
  • 605
  • 2
  • 6
  • 12
0

You will have to use ActivityManager.TaskDescription

Possible duplicate of this.

hsm59
  • 1,991
  • 19
  • 25