onSaveInstanceState Not recording data

Asked

Viewed 34 times

1

I have two activities that I will call activityA and acitivityB.

In my activityA I have the following method.

    @Override
    protected void onSaveInstanceState(Bundle bundle) {
       bundle.putString("ACTIVITY", "Dados que precisando ser salvos!");
       super.onSaveInstanceState(bundle);
    }

When I go to Activityb this above method is called. But when I go back to Activitya in the onCreate() method; my Bundle is null.

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    if (savedInstanceState != null){
        String teste = savedInstanceState.getString("ACTIVITY");
  }
}

Can anyone tell me why?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.