I need to hide the content of my application when it goes to the background so sensitive information are not showing up on the android multitasking view.

It's been suggested to use the following line to hide the screen

```
getWindow().setFlags(LayoutParams.FLAG_SECURE, LayoutParams.FLAG_SECURE);

```

It works fine.

However, this prevents the user from taking screenshot as well which is not an expected behavior for me. I want to let the user take screenshot of the app if they need to. What I don't want is Android to display the latest screen on the multitasking view.

Would it be possible to set the FLAG\_SECURE only when the app goes in the background?