Search code examples
androidscreen-captureandroid-13flag-secure

Android 13: FLAG_SECURE toast message is not showing


Our app does not allow screen capture, so below code is used:

if(android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
    window.setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE)
}

Whenever user tried to capture, some toast message from OS will show up like this: "Unable to capture screen, DRM protected image." But the things is, starting from Android 13, toast message doesn't show up. It just showing black blocked captured image at the left bottom corner.

Is there any way to display the user friendly message or toast?


Solution

  • It is totally OS dependent thing. Nothing developer can do. Not suitable for my case, but there's useful link using ContentObserver. https://proandroiddev.com/detect-screenshots-in-android-7bc4343ddce1