void setRequestedOrientation(int requestedOrientation) Change the desired orientation of this activity.
Parameter is one of these (from the [font=Courier New]android.content.pm.ActivityInfo[/font] Class):
int SCREEN_ORIENTATION_BEHIND Constant corresponding to behind in the screenOrientation attribute. 3
int SCREEN_ORIENTATION_LANDSCAPE Constant corresponding to landscape in the screenOrientation attribute. 0
int SCREEN_ORIENTATION_NOSENSOR Constant corresponding to sensor in the screenOrientation attribute. 5
int SCREEN_ORIENTATION_PORTRAIT Constant corresponding to portrait in the screenOrientation attribute. 1
int SCREEN_ORIENTATION_SENSOR Constant corresponding to sensor in the screenOrientation attribute. 4
int SCREEN_ORIENTATION_UNSPECIFIED Constant corresponding to unspecified in the screenOrientation attribute. -1
int SCREEN_ORIENTATION_USER Constant corresponding to user in the screenOrientation attribute. 2
XML:
This snippet rotates an Activity automatically based on the accelerometer.
Using xml Syntax Highlighting
- android:screenOrientation="sensor"
Parsed in 0.000 seconds, using GeSHi 1.0.8.4
Sample AndroidManifest.xml:
Using xml Syntax Highlighting
- ...
- <activity android:screenOrientation="sensor" android:name=".ui.map.WhereAmIMap" android:label="@string/app_name_whereami">
- <intent-filter>
- <action android:name="android.intent.action.DEFAULT" />
- <category android:name="android.intent.category.VIEW" />
- </intent-filter>
- </activity>
- ...
Parsed in 0.001 seconds, using GeSHi 1.0.8.4
Don not forget to implement onRestoreInstanceState and onSaveInstanceState to make the user-experience fluent
SDK Version compatible: 1.0 (maybe prior versions too)



