07.01.2013 Views

David Defour - Université de Perpignan

David Defour - Université de Perpignan

David Defour - Université de Perpignan

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Summary: Restoring Data<br />

• Overri<strong>de</strong> onRestoreInstanceState<br />

–Pass Bundle to superclass method<br />

–Look for data by name, check for null, use the data<br />

protected void onRestoreInstanceState(Bundle savedInstanceState) {<br />

super.onRestoreInstanceState(savedInstanceState);<br />

SomeType data = savedInstanceState.getBlah(key);<br />

if (data != null) { doSomethingWith(data); }<br />

}<br />

• Called<br />

–Any time app is restarted after onSaveInstanceState<br />

• Note<br />

519<br />

jeudi 26 janvier 12<br />

–The same Bundle is passed to onCreate.<br />

–Superclass method automatically restores widget state

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!