문제

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.

도움이 되었습니까?

해결책

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

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

다른 팁

I got this working by overriding onViewCreated like so in Kotlin:

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {

        this.dialog?.window?.setFlags(FLAG_SECURE, FLAG_SECURE)
        super.onViewCreated(view, savedInstanceState)
    }
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top