Lock the Orientation of an Android Activity

Here’s how you lock the orientation of an activity in Android:

Open your applications manifest file (usually AndroidManifest.xml) Add android:screenOrientation="portrait" to your activity’s attributes (or landscape if you want to lock it in landscape orientation) That’s it! An example of an activity element in the manifest would look like this:

<activity android:name=".MyActivity"