If you want to reject DialogFragment in onStop() , you most likely will not want to use DialogFragment , but the classic Dialog .
The reason DialogFragment exists is to allow the restoration of the dialog box automatically when activity is restored. If you release it in onStop() , it will never be restored.
In addition, if you use dismissAllowingStateLoss() , the reject transaction may be incorrectly written to onSaveInstanceState() (as the name says, a loss of state may occur), and this will lead to the restoration of the dialogue when the action is recreated, and obviously this is not that you want.
source share