What is “activity record object” in Android?

前端 未结 1 936
小蘑菇
小蘑菇 2021-02-03 13:11

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

Quoting article :

相关标签:
1条回答
  • 2021-02-03 14:14

    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.

    0 讨论(0)
提交回复
热议问题