Search code examples
androidkotlinandroid-toastandroid-securityandroid-drm

changing default FLAG_SECURE toast message in Android Kotlin


I have used the following code in my android app, to prevent the user from taking screenshots, or screen recording:

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

it shows the following toast message: "Unable to capture screen, DRM protected image."

how to change this toast message? i tried to search here in Stack Overflow answers but nothing helped, or if it's unchangeable, how to show another toast message with it when a screen record or capture is detected?


Solution

  • how to change this toast message?

    You can't. That message is coming from the OS, not your app. Whether such a message exists, and what it looks like and contains, will depend on the OS version and deivce manufacturer modifications.

    how to show another toast message with it when a screen record or capture is detected?

    You can't, as your app is not detecting these events. The OS is.