title: How to distinguish between orientation change and leaving application android
body: <p>I understand that when the orientation of the screen changes, the current activities onDestroy() is called followed by the onCreate() to effectively recreate the activity.
  I need to know how to programmatically tell if the application is being exited or if just the orientation is being changed.</p>
  
  <p>One method is for the previous activity to notify me when its onResume() method is being called, this will let me know that the user has pressed the back button and the orientation hasn't been changed.</p>
  
  <p>P.S. I'm looking for a solution more elegant than listening for a back hardware button click.</p>
  
  <p>Here was what i wanted to do:</p>
  
  <p>I have two tabs, when the activity is being entered for the first time or the user has left the activity and is now entering it, a certain tab is displayed based on some criterion.</p>
  
  <p>When the orientation changes, i need to stay on the same tab.</p>