Android Build an Interactive Story App The Rest of the Story Maintaining a Custom Back Stack

An easier, clearer way to do when backpressed on stack

public void onBackPressed() { pageStack.pop(); if(pageStack.isEmpty()) { super.onBackPressed(); }else{ int temp = pageStack.peek(); // save out what is on the top of the Stack // Psss (after you already poped once) pageStack.pop(); //pop it again, not to load the same page over itself loadPage(temp); // load what was on the top } } }