@@ -54,20 +54,25 @@ load alternative resources (such as the layout).</p>
5454<p>By default, the system uses the {@link android.os.Bundle} instance state to save information
5555about each {@link android.view.View} object in your activity layout (such as the text value entered
5656into an {@link android.widget.EditText} object). So, if your activity instance is destroyed and
57- recreated, the state of the layout is automatically restored to its previous state. However, your
57+ recreated, the state of the layout is restored to its previous state with no
58+ code required by you. However, your
5859activity might have more state information that you'd like to restore, such as member variables that
5960track the user's progress in the activity.</p>
6061
61- <p>In order for you to add additional data to the saved instance state for your activity, there's an
62- additional callback method in the activity lifecycle that's not shown in the illustration from
63- previous lessons. The method is {@link android.app.Activity#onSaveInstanceState
64- onSaveInstanceState()} and the system calls it when the user is leaving your activity. When the
65- system calls this method, it passes the {@link android.os.Bundle} object that will be saved in the
66- event that your activity is destroyed unexpectedly so you can add additional information to it. Then
67- if the system must recreate the activity instance after it was destroyed, it passes the same {@link
68- android.os.Bundle} object to your activity's {@link android.app.Activity#onRestoreInstanceState
69- onRestoreInstanceState()} method and also to your {@link android.app.Activity#onCreate onCreate()}
70- method.</p>
62+ <p class="note"><strong>Note:</strong> In order for the Android system to restore the state of
63+ the views in your activity, <strong>each view must have a unique ID</strong>, supplied by the
64+ <a href="{@docRoot}reference/android/view/View.html#attr_android:id">{@code
65+ android:id}</a> attribute.</p>
66+
67+ <p>To save additional data about the activity state, you must override
68+ the {@link android.app.Activity#onSaveInstanceState onSaveInstanceState()} callback method.
69+ The system calls this method when the user is leaving your activity
70+ and passes it the {@link android.os.Bundle} object that will be saved in the
71+ event that your activity is destroyed unexpectedly. If
72+ the system must recreate the activity instance later, it passes the same {@link
73+ android.os.Bundle} object to both the {@link android.app.Activity#onRestoreInstanceState
74+ onRestoreInstanceState()} and {@link android.app.Activity#onCreate onCreate()}
75+ methods.</p>
7176
7277<img src="{@docRoot}images/training/basics/basic-lifecycle-savestate.png" />
7378<p class="img-caption"><strong>Figure 2.</strong> As the system begins to stop your activity, it
0 commit comments