Android application screen can be prevent from taking screenshot via this code
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
super.onCreate(savedInstanceState);
}
But it is messy to write this code in every screen. Have any way to declare it in manifest application or any where.
Create a
BaseActivityfor your app and make all the other Activities extend it.Then you create your activities like this: