How to set app to be portrait only? [duplicate] How to set app to be portrait only? [duplicate] android android

How to set app to be portrait only? [duplicate]


As seen in the question:I want my android application to be only run in portrait mode?

You should set the configChanges and screenOrientation flags for every activity, and not at the root of your manifest.

So it should look like this:

<activity android:name=".MainActivity"  android:configChanges="orientation"  android:screenOrientation="portrait">    <intent-filter>        <action android:name="android.intent.action.MAIN"/>        <category android:name="android.intent.category.LAUNCHER"/>    </intent-filter></activity>


The android:screenOrientation must be in <activity> block. Also android:configChanges is not applicable to <application> but <activity> too.