Abhishek
Abhishek

Reputation: 61

Orientation of activities still changing even after disabling it

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/Theme.Fantasy">

        <activity
            android:name="view.StandingsActivity"
            android:label="@string/app_name"
            android:screenOrientation="portrait"
            android:configChanges="keyboardHidden|orientation|screenSize">
        </activity>

        <activity
            android:name="view.LoginActivity"
            android:label="@string/app_name"
            android:screenOrientation="portrait"
            android:configChanges="keyboardHidden|orientation|screenSize">    
        </activity>

        <activity
            android:name="view.RegisterActivity"
            android:label="@string/app_name"
            android:screenOrientation="portrait"
            android:configChanges="keyboardHidden|orientation|screenSize">    
        </activity>

        <activity
            android:name="view.PlayerStandingsActivity"
            android:label="@string/app_name"
            android:screenOrientation="portrait"
            android:configChanges="keyboardHidden|orientation|screenSize">    
        </activity>

        <activity
            android:name="view.ScheduleActivity"
            android:label="@string/app_name"
            android:screenOrientation="portrait"
            android:configChanges="keyboardHidden|orientation|screenSize">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity
            android:name="view.MatchStatsActivity"
            android:label="@string/app_name"
            android:screenOrientation="portrait"
            android:configChanges="keyboardHidden|orientation|screenSize">    
        </activity>

        <activity
            android:name="view.PlayerDetailsActivity"
            android:label="@string/app_name"
            android:screenOrientation="portrait"
            android:configChanges="keyboardHidden|orientation|screenSize">    
        </activity>

        <activity
            android:name="view.PlayerStatsActivity"
            android:label="@string/app_name"
            android:screenOrientation="portrait"
            android:configChanges="keyboardHidden|orientation|screenSize">
            </activity>

        <activity
            android:name="view.AwardsActivity"
            android:label="@string/app_name"
            android:screenOrientation="portrait"
            android:configChanges="keyboardHidden|orientation|screenSize">
        </activity>

        <activity
            android:name="view.TeamActivity"
            android:label="@string/app_name"
            android:screenOrientation="portrait"
            android:configChanges="keyboardHidden|orientation|screenSize">
        </activity>

        <activity
            android:name="view.AddPlayersActivity"
            android:label="@string/app_name"
            android:screenOrientation="portrait"
            android:configChanges="keyboardHidden|orientation|screenSize">
        </activity>

    </application>

This is a part of my manifest file. I have specified to disable the landscape mode, but still the orientation changes when screen is rotated. What have I missed? Do I have to add any permissions in here?

Upvotes: 0

Views: 65

Answers (2)

Amit Vaghela
Amit Vaghela

Reputation: 22945

When android:screenOrientation="portrait" or "landscape" are set in the manifest file no listeners are fired still if u want to do it try handling the portrait only mode in ur onConfigurationChanged() programatically and here u will also be able to start the activity again.

checkout Documentation on OrientationListener.

Upvotes: 1

tsiro
tsiro

Reputation: 2393

you can override the onConfigurationChanged method of each of your activity to handle orientation changes by yourself..otherwise declaring android:configChanges in your manifest file you are not able to handle them at all..

@Override 
public void onConfigurationChanged(Configuration newConfig) {
   super.onConfigurationChanged(newConfig);
   setRequestedOrientation(ActivityInfo."orientation type your preffer");
} 

Upvotes: 2

Related Questions