i used the below link to prevent to take screenshot but this will take more time to prevent taking the screenshot after executing the code which is going to prevent the taking of screenshot.
How do I prevent Android taking a screenshot when my app goes to the background?
Code:
if(android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
}
Phone: galaxy s6 Os: 5.1.1