Prevent screen shots

I’m trying to create an Android plugin to prevent screenshots while running the app. From what I have read I need to call the following in the Activity onCreate handler…

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

But I have not been able to get this to work. I have tried extending UnityPlayerActivity, UnityPlayerNativeActivity, and even android.app.NativeActivity. I have verified that the plugin itself is working properly (I am able to call other functions in the plugin) and the onCreate method is getting executed.

I have tried setting the flags in multiple places inside onCreate, such as before and/or after setContentView(mUnityPlayer), but it never works.

I’m testing on an HTC One m8. Anyone know what the problem could be?

1 Like

I am facing same problem :(:(:(:frowning:

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

This code is not working