How to disable orientation change (i.e only Landscape mode or only potrait mode) in android

If you want your android app not to change orientation when the user changes the orientation.

You can do it both programatically or updating the manifest file.

1) Updating the Manifest.

Just add this line to the activity that you want for a particular activity

android:screenOrientation="portrait"

It would look like 
 <activity
            android:name="com.example.Activity"
            android:label="Example" 
            android:screenOrientation="portrait">
        </activity>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s