Skip to content

Save instance state

pyricau edited this page Mar 13, 2012 · 3 revisions

Since AndroidAnnotations 2.5

You can save the instance state of your activity when it is destroyed by annotating your attributes :

@EActivity
public class MyActivity extends Activity {

    @InstanceState
    int someId;

    @InstanceState
    MySerializableBean bean;

}

The attributes values are automatically saved when the system call [onSaveInstanceState(Bundle)](http://developer.android.com/reference/android/app/Activity.html#onSaveInstanceState(android.os.Bundle\)). All of those values are restored when [onCreate(Bundle)](http://developer.android.com/reference/android/app/Activity.html#onCreate(android.os.Bundle\)) is called by the system.

Wiki

Using AndroidAnnotations

Questions?

Developing AndroidAnnotations

Misc

Clone this wiki locally