There are many answers, but when the dialog box opens, the application crashes. Record getDialog().setCanceledOnTouchOutside(true); inside onCreateView did not work and crashed my application.
(I use AppCompatActivity as my BaseActivity and android.app.DialogFragment as my fragment).
Which works, either one of the following two lines:
getDialog () setCanceledOnTouchOutside (true) ;.
OR
this.getDialog () setCanceledOnTouchOutside (true) ;.
inside onActivityCreated as
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState);
What not to use:
DialogFragment.getDialog () setCanceledOnTouchOutside (false) ;.
causes the following error

And writing code to onCreateView crashes the application! Update your answer if you find something is wrong.
sud007 Apr 6 '17 at 8:48 2017-04-06 08:48
source share