Doesn't work onSaveInstanceState



  • I have an active activity with two methods ( maintain and resume variable):

    public class DataActivity extends FragmentActivity implements ViewPager.OnPageChangeListener, LoaderManager.LoaderCallbacks<ArrayList<ArrayList<ArrayList<String>>>> {
        ...
        ...
        ...
    
    private final static String KEY_IS_LOAD_FINISHED = "LOAD_FINISHED";
    private boolean isLoadFinished = false;
    
    @Override
    public void onSaveInstanceState(Bundle outState, PersistableBundle outPersistentState) {
        super.onSaveInstanceState(outState, outPersistentState);
        outState.putBoolean(KEY_IS_LOAD_FINISHED, isLoadFinished);
    }
    
    @Override
    protected void onRestoreInstanceState(Bundle savedInstanceState) {
        super.onRestoreInstanceState(savedInstanceState);
        isLoadFinished = savedInstanceState.getBoolean(KEY_IS_LOAD_FINISHED);
    }
    
    ...
    ...
    ...
    

    }

    The problem is, onRestoreInstaceState Called, a онSaveInstanceState - No. I've seen the logs. But why?



  • You're kind of wrong. onSaveInstanceState You use it. In the original signature of the method you need, you don't have a second argument like this:

    @Override
    public void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        ...
    }
    

    The method you use is designed to restore the activate after rebooting the moisture. And requires an additional attachment in the creation of an activist. See the docks on this account: http://developer.android.com/intl/ru/reference/android/app/Activity.html#onSaveInstanceState(android.os.Bundle,%20android.os.PersistableBundle)




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2