Why dismiss method call needed to clear the DialogFragment from view

when tackling the challenge 2 and using onCreateView( ) we need to use dismiss( ) in the onClickListener( ) method of the OK button hosted by the DatePickerFragment layout to dismiss the dialog and go back to the CrimeFragment. if we do not do it, the model is updated but the dialog is still visible - we need to press the back button to dismiss it. whereas if we took the onCreateDialog route and created the AlertDialog as given in the book the dialog is automatically dismissed on pressing the OK button of the AlertDialog. Why is this so? Even in the earlier chapters we never had to use dismiss( ) to remove a child fragment from visible status. Any ideas? Thanks.

Sudeep.

Hello!
When we use the onCreateDialog with AlertDialog, internally (probably) the dialog call the dismiss method when we touch any of the buttons (positive, negative or neutral), but when using onCreateView and creating all the things by your own, we must do things like calling dismiss. I’m not sure about it, it’s just a guess.