FLAG_SECURE无法在样式为DialogFragment.STYLE_NO_TITLE的DialogFragment上使用 [英] FLAG_SECURE not working on DialogFragment with style as DialogFragment.STYLE_NO_TITLE
问题描述
当我设置对话框片段的样式时,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
之前,请在DialogFragment
的onCreate()
中创建的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屋!