You can store the last known page index in a field at the end of onPageSelected
(initialize it with an appropriate default when your activity starts). Then, inside onPageSelected
, you check that field to see what page the user was previous on.
private int mLastPage;
@Override
public void onPageSelected(int position) {
// save the information from the page at mLastPage
mLastPage = position;
}