Friday, 11 October 2019

Prohibit Screenshot in your android App

Prohibit Screenshot in your android App.


If you want to stop screenshot in all screen of your app then you need to create a BaseActivity and extend this activity to all your activity in which you want to stop screenshot.
Add below mentioned line in onCreate method of BaseActivity.
--------------------------- OR -----------------------------
If you want to prohibit screenshot in particular screen then add below mentioned line if specific activity.
getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, 
WindowManager.LayoutParams.FLAG_SECURE);