Skip to content

Save instance state

Damien edited this page Mar 4, 2014 · 6 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). All of those values are restored when onCreate(Bundle) is called by the system.

Since AndroidAnnotations 2.7

You can also use @InstanceState in a fragment annotated with @EFragment.

Using AndroidAnnotations

Questions?

Enjoying AndroidAnnotations

Improving AndroidAnnotations

Clone this wiki locally