Fragment Plus viewpager do tab when easy out of this null pointer exception, see Source:
if (f.msavedviewstate! = null) { if (result = = null) { result = new Bundle (); } Result.putsparseparcelablearray ( Fragmentmanagerimpl.view_state_tag, f.msavedviewstate);} if (!f.muservisiblehint) { if (result = = null) { result = new Bundle (); } Only add this if it's not the default value Result.putboolean (Fragmentmanagerimpl.user_visible_hint_tag, F.muservisiblehint);}
The non-saved state enters the second if null-throw pointer exception.
Add the following code to the fragment to solve the bug:
@Override public void Onsaveinstancestate (bundle outstate) {//first Saving my state, so the bundle wont is empty.outstate. Putstring ("KEY", "Wbug_value"); Super.onsaveinstancestate (outstate);}
Or:
Class Myfragment extends Fragment { @Override public void Onsaveinstancestate (Bundle outstate) { Super.onsaveinstancestate (outstate); Setuservisiblehint (True); }
or use Fragmentstatepageradapter insteadFragmentpageadapter.
NullPointerException android.support.v4.app.FragmentManagerImpl.saveFragmentBasicState