Android Programming Tutorials

(Romina) #1

TUTORIAL 14


Turn, Turn, Turn


In this tutorial, we will make our application somewhat more intelligent


about screen rotations, ensuring that partially-entered restaurant


information remains intact even after the screen rotates.


Step-By-Step Instructions.........................................................................


First, you need to have completed the previous tutorial. If you are


beginning the tutorials here, or if you wish to not use your existing work,


you can download a ZIP file with all of the tutorial results, and you can copy


the 13-Prefs edition of LunchList to use as a starting point.


Step #1: Add a Stub onSaveInstanceState()......................................


Since we are not holding onto network connections or other things that


cannot be stored in a Bundle, we can use onSaveInstanceState() to track our


state as the screen is rotated.


To that end, add a stub implementation of onSaveInstanceState() to


DetailForm as follows:


@Override
public void onSaveInstanceState(Bundle state) {
super.onSaveInstanceState(state);
}

147
Free download pdf