onSaveInstanceState is not saving my values ( onCreate input Bundle is always null )

前端 未结 6 1458
轻奢々
轻奢々 2020-12-10 12:19

Saving bundle (activity A):

@Override
protected void onSaveInstanceState(Bundle outState) {
    outState.putString(\"test\", \"value\");
    super.onSaveInst         


        
6条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-10 12:56

    If navigating to another Activity and coming back, best way is to save it to SharedPreference in the onPause() method, which is bound to execute when a new activity is loaded. On the other Activity, the value can be accessed in onCreate() by accessing the shared preference.

提交回复
热议问题