The important point is that the
Activity
’s
onDestroy
and
onCreate
methods are called whenever the orientation changes.
MainActivity.java
activity_main.xml
:
added
android:id
attribute to
TextView
.AndroidManifest.xml
:
added
android:screenOrientation="fullSensor"
attribute to
<activity>
element.
The keystrokes that change the orientation of the emulator are different on Mac and PC.
Eclipse gives us a default
AndroidManifest.xml
file whose
activity
element does not have the
android:screenOrientation
"unspecified"
,
which means the device can do whatever it wants.
With the default value,
the emulator was able to go to
“portrait 0”
and
“landscape 90”.
My Motorola Sprint MB612 (Android 2.3.5, SDK 10) went to
was also able to go to
“landscape 270”.
Adding the
android:screenOrientation="fullSensor"
attribute had no effect on the
emulator;
my phone gained
“portrait 180”.
iOS, by the way, has six orientations, including face up and face down.