How to detect if view's parent activity is being destroyed
If you want to get a callback without having to overload the View.onDetachedFromWindow()
method, you may use the View.addOnAttachStateChangeListener()
method, which takes a callback listener as a single parameter.