Android onSaveInstanceState 捆绑包
Android onSaveInstanceState Bundle
当 android 由于系统限制而终止您的进程时,它使您能够通过将数据存储在一个包中来跨进程持久保存数据。如果您的进程被终止,这个包保存在哪里?它存在于哪个进程中?它住在记忆中的什么地方?它存在于内核内存中吗?
内核内存是受保护的内存space,其中仅驻留内核代码等关键代码。这是为了防止来自用户的数据和内核的数据的干扰,以及其他性能和设计原因。内核内存将在重启后保留。
Bundle 中保存的数据在 onSaveInstanceState() 的方法中传递 - 在用户离开 Activity 之前而不是在 Activity 被销毁之前。这可能意味着内存没有像存储卡那样写入静态内存区域。 Bundle 确实会以更动态的方式持久化。
虽然没有直接回答这个问题,但看起来这是 RAM 上的内存。当您查看 Android 设备的性能时,具有更多 RAM 的最新设备似乎能够更长时间地保留应用程序
从http://developer.android.com/training/basics/activity-lifecycle/recreating.html的官方文档可以看出,这段内存是由Android自己跟踪的。
By default, the system uses the Bundle instance state to save
information about each View object in your activity layout (such as
the text value entered into an EditText object). So, if your activity
instance is destroyed and recreated, the state of the layout is
restored to its previous state with no code required by you. However,
your activity might have more state information that you'd like to
restore, such as member variables that track the user's progress in
the activity.
To save additional data about the activity state, you must override
the onSaveInstanceState() callback method. The system calls this
method when the user is leaving your activity and passes it the Bundle
object that will be saved in the event that your activity is destroyed
unexpectedly. If the system must recreate the activity instance later,
it passes the same Bundle object to both the onRestoreInstanceState()
and onCreate() methods.
另请记住,当设备关闭时,此 Bundle 会被销毁。 Android 可能有专门为此设计的内存区域,但无论哪种方式,它都在 RAM 中的某个地方。
当 android 由于系统限制而终止您的进程时,它使您能够通过将数据存储在一个包中来跨进程持久保存数据。如果您的进程被终止,这个包保存在哪里?它存在于哪个进程中?它住在记忆中的什么地方?它存在于内核内存中吗?
内核内存是受保护的内存space,其中仅驻留内核代码等关键代码。这是为了防止来自用户的数据和内核的数据的干扰,以及其他性能和设计原因。内核内存将在重启后保留。
Bundle 中保存的数据在 onSaveInstanceState() 的方法中传递 - 在用户离开 Activity 之前而不是在 Activity 被销毁之前。这可能意味着内存没有像存储卡那样写入静态内存区域。 Bundle 确实会以更动态的方式持久化。
虽然没有直接回答这个问题,但看起来这是 RAM 上的内存。当您查看 Android 设备的性能时,具有更多 RAM 的最新设备似乎能够更长时间地保留应用程序
从http://developer.android.com/training/basics/activity-lifecycle/recreating.html的官方文档可以看出,这段内存是由Android自己跟踪的。
By default, the system uses the Bundle instance state to save information about each View object in your activity layout (such as the text value entered into an EditText object). So, if your activity instance is destroyed and recreated, the state of the layout is restored to its previous state with no code required by you. However, your activity might have more state information that you'd like to restore, such as member variables that track the user's progress in the activity.
To save additional data about the activity state, you must override the onSaveInstanceState() callback method. The system calls this method when the user is leaving your activity and passes it the Bundle object that will be saved in the event that your activity is destroyed unexpectedly. If the system must recreate the activity instance later, it passes the same Bundle object to both the onRestoreInstanceState() and onCreate() methods.
另请记住,当设备关闭时,此 Bundle 会被销毁。 Android 可能有专门为此设计的内存区域,但无论哪种方式,它都在 RAM 中的某个地方。