Russell Stewart
Russell Stewart

Reputation: 1960

My Android app rotates even if screen rotation is disabled in the OS. How can I fix this?

I am developing an Android app that has full support for landscape mode. All of my activities have the following properties set in the manifest:

android:configChanges="keyboardHidden|locale|orientation"
android:screenOrientation="sensor"

However, if I disable rotation in the phone's Screen settings, my app still rotates when the phone is rotated. This kind of bothers me; it seems like the whole point of a system-level setting is moot if it can be overriden by an individual app. How can I fix this so it follows the system-level setting while still behaving properly if screen rotation is enabled on the phone?

Upvotes: 4

Views: 5785

Answers (3)

Amit Patel
Amit Patel

Reputation: 1825

you can add android:screenOrientation="user" and make sure there is no SCREEN_ORIENTATION_SENSOR in the java code or manifest.

Upvotes: 1

CaseyB
CaseyB

Reputation: 25058

You could try using

android:screenOrientation="user"

Upvotes: 11

Lucifer
Lucifer

Reputation: 29670

You can try other way like this ,

android:screenOrientation="landscape" 
android:configChanges="orientation|keyboardHidden"

apply these attributes after the activity name in AndroidManifest.xml file.

Upvotes: 0

Related Questions