@Override public Parcelable saveState() { Parcelable p = super.saveState(); Bundle bundle = new Bundle(); bundle.putParcelable(ADS_FRAGMENT_STATE_SUPER_STATE, p); bundle.putInt(ADS_FRAGMENT_STATE_PAGES, mPages.size()); if (0 < mPages.size()) { for (int i = 0; i < mPages.size(); i++) { int position = mPages.keyAt(i); bundle.putInt(createCacheIndex(i), position); Fragment f = mPages.get(position); mFragmentManager.putFragment(bundle, createCacheKey(position), f); } } return bundle; }