Safety Dialog

When opening dialog, sometimes error happens.
Dialog should be connected with Activity. If missing Activity, we cannot open Dialog
What case? “Back” button is easy to destroy Activity.

Error is following
android.view.WindowManager$BadTokenException: Unable to add window — token android.os.BinderProxy@xxxxx is not valid; is your activity running?

Safety Open

Using isFinishing to check Activity

if ( !this.isFinishing() ) {
   // You can open dialog.