Protect Your Content

FLAG_SECURE

On Android, you can set FLAG_SECURE on WindowManager.LayoutParams to preventing content from appearing in screenshots. This flag also takes effect in VR runtime. Set FLAG_SECURE flag will prevent VR content appearing in screenshots and even Miracast.

To make its effect, make sure set flag before VRActivity.onCreate().

Here is an example for the function:

public class MainActivity extends VRActivity {
    ...
    ...
    @Override
    protected void onCreate(Bundle icicle) {
        Log.i(TAG,"onCreate:call init");
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
        super.onCreate(icicle);
        ...
        ...
    }
    ...
    ...
}

Reference: Android developer docs