Where is the bundle of onSaveInstanceState saved?

后端 未结 5 1943
旧巷少年郎
旧巷少年郎 2020-12-15 18:21

I would like to know where the bundle \"outState\" of the method onSaveInstanceState(Bundle outState) is stored.

Is it stored in memory or in the device storage?

5条回答
  •  臣服心动
    2020-12-15 18:53

    Here is a detailed answer for where the outState Bundle data is saved:

    ...Bundles are an IPC mechanism, so it's not going to the filesystem. But now there's a P involved – which process is it? And what is that process doing with this data? And do I need to be worried about it? It turns out that these instance state bundles are stored in the Activity Manager service. This service is implemented under the package com.android.server.am in the Android source code. Recall that Activities are stacked one on top of another and that Android calls these stacks “Tasks”... Each of these tasks is represented internally with an object of class TaskRecord. This class contains an array of ActivityRecord objects, each of which manages the state of an Activity. ActivityRecord contains a member of type Bundle named icicle. This icicle-bundle is the saved instance state and it is actually stored in the memory space of the Activity Manager service.

    Source: https://www.linkedin.com/pulse/android-onsaveinstancestate-bundle-secret-safe-daniel-pietsch/

提交回复
热议问题