SoFunction
Updated on 2025-04-04

Detailed explanation of the usage method of onSaveInstanceState in Android

Detailed explanation of the usage method of onSaveInstanceState() in Android

Override the onSaveInstanceState method and detect savedInstanceState and get saved value in onCreate


@Override 
protected void onSaveInstanceState(Bundle outState) {  
  ("currentposition", ()); 
  (outState); 
} 

public void onCreate(Bundle savedInstanceState) { 
  (savedInstanceState); 
  setContentView();  

  initView(); 

  if (savedInstanceState != null 
      && ("currentposition") != 0) { 

    (("currentposition")); 
  } 
} 

If you have any questions, please leave a message or go to the community of this site to exchange and discuss. Thank you for reading. I hope it can help you. Thank you for your support for this site!