title: Get next element of Back-Stack in Android
body: <p>I want to change the behaviour of my back button.
  I already found out that I have to override the onBackPressed()-Method.
  I'd like to check then, if a function like <code>getActivity().popBackStackItem()</code> returns activity (or whatever) X or something different from the BackStack of the system. In case of result is activity X, I want to change the behaviour (to close the app for example), otherwise the super-method shall be called and the activity of the BackStack shall be executed.</p>
  
  <p>Main question is: Does a function like <code>popBackStackItem()</code> exists? Didn't found something like this until yet.</p>
  
  <p>I already had a look <a href="http://developer.android.com/training/implementing-navigation/temporal.html" rel="nofollow">here</a>, but I don't want to create a completely new stack, I think checking the content in the system-wide BackStack should be enough here.</p>