androidfragmentscreenshotrestrictdialogfragment

how to add FLAG_SECURE flag to DailogFragment


I have to restrict user to take screenshot. So I want to add FLAG_SECURE flag in my class which extends DialogFragment. Can anyone please tell me where and how to add that flag. Thanks in advance.


Solution

  • You must set it in your onCreate method of your FragmentActivity :

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