The lifecycle
module contains extensions to make dialogs work with AndroidX lifecycles.
dependencies {
...
implementation 'com.afollestad.material-dialogs:lifecycle:3.2.1'
}
MaterialDialog(this).show {
...
lifecycleOwner(owner)
}
When the given lifecycle owner is destroyed, the dialog is automatically dismissed. Lifecycle
owners include Activities and Fragments from AndroidX, along with any class that implements the
LifecycleOwner
interface.