13

With FLAG_SECURE, screen capture is not allowed. I would like my application to be able to capture the screen, but to be blured or hidden when it goes to the background.

Would you know any way to do this? Is it possible to do it with FLAG_SECURE?

I read this topic (Android : Unable to screenshot after using method FLAG_SECURE) but nobody have any valid answer for that.

The use of FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS exclude the app to appear on recents apps, but not sure if prevent the android system to take and store the status screenshoot.

Any suggestion Thanks

A981K
  • 193
  • 1
  • 1
  • 7
  • Have a look at this https://stackoverflow.com/questions/37189914/android-customize-your-recent-screens-appear-here-your-recent-apps-scree – Mohamed Mohaideen AH Sep 05 '18 at 14:07
  • Possible duplicate of [Android - customize "your recent screens appear here" / "your recent apps" screen](https://stackoverflow.com/questions/37189914/android-customize-your-recent-screens-appear-here-your-recent-apps-scree) – Zoe Sep 05 '18 at 14:59
  • Hi! Thanks for the comment, looks nice, however, I was thinking about security. Using this the app is not displayed on the opened task, but, is the screenshoot created? In affirmative case, the security issue remains the same. Thanks :) – A981K Sep 05 '18 at 15:13
  • 1
    Is there any solution for this problem which works on older versions of Android? – Ban Markovic Oct 11 '19 at 08:14
  • Any other solution for that issue on these days? :( – Emre Tekin Nov 25 '19 at 08:57

1 Answers1

7

It is indeed possible.

public override fun onPause() {
    window.addFlags(WindowManager.LayoutParams.FLAG_SECURE)
    super.onPause()
}

public override fun onResume() {
    super.onResume()
    window.clearFlags(WindowManager.LayoutParams.FLAG_SECURE)
}

This basically sets secure flags only when the app is thrown to background and clears flags on entering to foreground, so you will be able to make screenshots. I use this code in some abstract Activity.

Bio-Matic
  • 793
  • 1
  • 8
  • 20