Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is "activity record object" in Android?

I was referring to following article to further understand the life cycle of the activity and found phrase "activity record object"

Quoting article :

When your activity is stashed, an Activity object does not exist, but the activity record object lives on in the OS.The OS can reanimate the activity using the activity record when it needs to.


When onSaveInstanceState(...) is called, the data is saved to the Bundle object.That Bundle object is then stuffed into your activity's activity record by the OS

Could any one define exactly what is meant by "activity record object", and does OS save considerable amount of memory by just killing an activity ?

like image 334
nish1013 Avatar asked Aug 08 '13 13:08

nish1013


1 Answers

I wrote the passage you quote here (it's from the book Brian Hardy and I wrote, Android Programming: The Big Nerd Ranch Guide). Let me see if I can answer your questions.

The "activity record object" (I usually say "activity record") is not visible to you as an application developer. Instead, it lives in the Android OS, where it is used to keep track of your activity. That object is where your saved instance state is stored; it's where the intent that initially started your activity lives, where the activity results you receive are stored before they are delivered. More importantly, if the activity record is alive, it may be used to reconstitute an Activity instance in your application.

The activity record object is much cheaper to keep alive than an instance of the Activity class. An Activity instance has a whole view hierarchy, which can easily take up a few megabytes of memory by itself. On top of that, Activity instances require your app's process to exist. So if there are no Activity instances left, Android can get rid of your entire process, too.

like image 106
Bill Phillips Avatar answered Nov 02 '22 18:11

Bill Phillips