title: Dismissing dialog on activity finish
body: <p>In my app I have several activities one after the other. After my login screen I have Home screen and after that several screens. Now When user select device home button or power off button I want to display login screen when user again comes to my app and then Home screen. Rest all activity I am finishing it from my base class. Now till here I have done, My problem is when I show a dialog in some other activity and at that instance if user click on home or power button, then i am getting <strong>WINDOW LEAKED EXCEPTION</strong>. </p>
  
  <p><img src="https://i.stack.imgur.com/6BZTT.jpg" alt="enter image description here"></p>
  
  <p>Like I have TempActivity is displaying a dialog and user clicked home button so StoreActivity and TempActivity will finish but Dialog never got chance to be dismissed. So What would be the best way to deal with this situation.
  Is there some better way to dismiss the dialog so that I don't get any exception.</p>