I'm using DialogFragment and in the onCreateDialog I need to use the Activity's reference. The issue is that with the latest support library (28.0.0), the activity becomes nullable, so when using AlertDialog.Builder in onCreateDialog I'm forced to use !!
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
[...]
val dialog = AlertDialog.Builder(activity!!).setTitle(R.string.title)[...].create()
[...]
return dialog
}
I can't add any null check because I need to return a dialog anyway. Is there any clean solution to avoid to use !! operator?