Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Will 'Bundle savedInstanceState' be alive after Application is being killed?

Tags:

android

Will savedInstanceState bundle in onCreate() method be alive (not null) after Application is being killed? If it would, where this bundle is stored in the system.

like image 357
Eugene Avatar asked May 30 '13 13:05

Eugene


People also ask

Why we use bundle savedInstanceState in Android?

The savedInstanceState is a reference to a Bundle object that is passed into the onCreate method of every Android Activity. Activities have the ability, under special circumstances, to restore themselves to a previous state using the data stored in this bundle.

How do you save onSaveInstanceState?

1 Answer. Show activity on this post. You can replace above with the data you want to save and then re-populate your views like RecyclerView etc with the data you saved in the savedInstance as key-value pair. Just keep in mind that the Bundle is not meant to store Large amount of data.

What is the use of protected void onCreate bundle savedInstanceState?

After Orientation changed then onCreate(Bundle savedInstanceState) will call and recreate the activity and load all data from savedInstanceState. Basically Bundle class is used to stored the data of activity whenever above condition occur in app. onCreate() is not required for apps.

Why is savedInstanceState null?

The logs always show the "bundle save" tag. But in onCreate method, SavedInstanceState is always null. you need to call super. onSaveInstanceState(savedInstanceState) before adding your values to the Bundle, or they will get wiped out on that call (Droid X Android 2.2).


1 Answers

If Android kills the process hosting your app, it still maintains the "saved instance state" of all active (non-finished) activities. This data is stored by the ActivityManager. If the user returns to your application, Android will create a new process for the app, instantiate the Application instance again and then create an instance of the top activity in the activity stack. It will then call onCreate() on that activity instance passing it the "saved instance state" that was most recently saved for that activity.

If you reboot your phone, all this data is lost (Android does not save application state across reboots).

like image 59
David Wasser Avatar answered Oct 29 '22 13:10

David Wasser