I am developing an Android app whose orientation I don\'t want changed to landscape mode when the user rotates the device. Also, I want the locked orientation to be portrait
You just have to define the property below inside the activity element in your AndroidManifest.xml
file. It will restrict your orientation to portrait.
android:screenOrientation="portrait"
Example:
Additionaly, as per Eduard Luca's comment below, you can also use screenOrientation="sensorPortrait"
if you want to enable rotation by 180 degrees.