0

I want to disable screenshot but in some versions it is not working.

I have called registerActivityLifecycleCallback(this) in onCreate() method.

Is screenshot disable functionality varies with different versions of Android? Anyone have any idea about this?

Asteroid
  • 718
  • 7
  • 21
  • 1
    Does this answer your question? [How to prevent Screen Capture in Android](https://stackoverflow.com/questions/28606689/how-to-prevent-screen-capture-in-android) – Victor Oliveira Aug 21 '22 at 08:58

3 Answers3

0

As per analysis, restrictions of screenshot below code will work but it will not work on Oxygen Os version 9, because they made OS like that user can take screenshots. It is also mentioned on OnePlus forum.

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

Asteroid
  • 718
  • 7
  • 21
0

in kotlin, use:

window.setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE)
Tareq
  • 1
  • 1
0

You may use:

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

in your onCreate method.

Daljit Singh
  • 270
  • 3
  • 10