FLAG_SECURE not working on DialogFragment with style as DialogFragment.STYLE_NO_TITLE

坚强是说给别人听的谎言 提交于 2020-01-04 14:11:14

问题


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.

Below is the code of dialog fragment's 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?


回答1:


AFAICT, using FLAG_SECURE on the hosting activity is insufficient to make a DialogFragment 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.



来源:https://stackoverflow.com/questions/32440679/flag-secure-not-working-on-dialogfragment-with-style-as-dialogfragment-style-no

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!