kassim
kassim

Reputation: 4009

How to set thumbnail for Recent Apps screen?

My app shows sensitive information that I don't want showing up in the 'Recent Apps' screen so I'd like to change what is shown there, or have it show nothing.

I've seen an answer from a few years ago about using Activity.onCreateThumbnail() but it doesn't seem to work. getWindow().addFlags(FLAG_SECURE) achieves this but I don't want to prevent users from taking screenshots.

Is there a way I can achieve what I need?

Upvotes: 1

Views: 1280

Answers (1)

Pankaj
Pankaj

Reputation: 8058

I am late to answer but think this can be done easily you need to use onWindowFocusChanged method. Here is how you can define in your activity.

@Override
public void onWindowFocusChanged(boolean hasFocus) {
    yourViewWhichNeedtobeShowninRecentScreen.setVisibility(hasFocus ? View.GONE : View.VISIBLE);
    super.onWindowFocusChanged(hasFocus);
}

But there is a catch if you show any dialog or bottom sheet window when window is not focused it will show that recent app view in background which you set in "onWindowFocusChanged" method.

Upvotes: 0

Related Questions