FLAG_SECURE无法在样式为DialogFragment.STYLE_NO_TITLE的DialogFragment上使用 [英] FLAG_SECURE not working on DialogFragment with style as DialogFragment.STYLE_NO_TITLE

查看:175
本文介绍了FLAG_SECURE无法在样式为DialogFragment.STYLE_NO_TITLE的DialogFragment上使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我设置对话框片段的样式时,android允许拍摄对话框片段的屏幕截图,但是在删除样式后,它就可以使用了.

When I set the style of a dialog fragment, the android is allowing to take the screen shot of dialog fragment, but after removing the style it works.

下面是对话框片段onCreate

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setStyle(DialogFragment.STYLE_NO_TITLE, android.R.style.Theme_Holo_Light);
    getActivity().getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
    setCancelable(false);
}

以前有没有其他人遇到过类似的问题?

Has any one else faced a similar issue before?

推荐答案

AFAICT,在托管活动中使用FLAG_SECURE不足以确保DialogFragment安全.

AFAICT, using FLAG_SECURE on the hosting activity is insufficient to make a DialogFragment secure.

除了对活动使用FLAG_SECURE之外,在返回Dialog之前,请在DialogFragmentonCreate()中创建的Dialog上调用getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);.

In addition to using FLAG_SECURE for the activity, call getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE); on the Dialog that you create in onCreate() of the DialogFragment, before you return that Dialog.

这篇关于FLAG_SECURE无法在样式为DialogFragment.STYLE_NO_TITLE的DialogFragment上使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆