0

When Android backgrounds an application it creates a screenshot of the current screen. The screenshot is displayed when you click the Overview button.

Is there a way to prevent this backgrounding screen shot (as if I'd used FLAG_SECURE), but allow the users to take screenshots?

Martin
  • 139
  • 4
  • 12

2 Answers2

0

You can configure not to show your activity in recent list. Add following code in manifest :

    <activity
        .....
        android:excludeFromRecents="true"
        ...../>

Or from java code startActivity with flag:

intent.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);

Or,

<activity
    .....
    android:noHistory="true"
    ...../>
  • Unfortunately neither of the excludeFromRecents work for me with sdk 22 and Android v6.0.1 (its an S7). The app is not the first started after a reboot. I'll need to preserve the history so noHistory isn't an option either. – Martin Feb 05 '17 at 22:16
0

Try this https://stackoverflow.com/a/49442984/5939067 .

The solution above simply sets the secure flag when your app goes background, and clears it when it resumes(so you can take the screenshot while using the app).

It works perfectly for me. I tested with Samsung Galaxy 9+(Android 9), LG V30(Android 8) and LG G7 ThinQ(Android 8).