I want to keep landscape mode always. I Lock screen to portrait mode on Nexus7, I set android:screenOrientation="sensorLandscape" and android:configChanges="orientation|keyboardHidden"in AndroidManifest.xml, when I go to other activity and back to this activity, then the screen will rotate portrait and rotate to landscape again (Didn't call onCreate method again), but I don't want to rotate the screen in any situations, how to fix it?
Asked
Active
Viewed 4,696 times
0
-
`he screen will rotate portrait and rotate to landscape again `. Can you explain this again please? You can also try adding `screenSize` to `configChanges`. i.e `android:configChanges="keyboardHidden|orientation|screenSize"` – Shobhit Puri Aug 30 '13 at 03:18
-
4`screenOrientation:landscape` in the `
– Ali Aug 30 '13 at 03:21 -
I mean the nexus7's screen will rotate 90 to portrait mode, and then rotate 90 to landscape automatically – Lijun Lou Aug 30 '13 at 06:41
-
Possible duplicate of [Prevent screen rotation on Android](https://stackoverflow.com/questions/2730855/prevent-screen-rotation-on-android) – sameer Mar 09 '18 at 06:05
4 Answers
1
For All your Activities in the manifest set
android:screenOrientation="sensorLandscape" android:configChanges="orientation|keyboardHidden"
Example :-
<activity android:name="com.example.test.testActivity" android:label="@string/app_name" android:screenOrientation="sensorLandscape" android:configChanges="orientation|keyboardHidden"">
<intent-filter>
<action android:name="com.example.test.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
Repeat this for all activities used in the manifest..

Augustus Francis
- 2,694
- 4
- 22
- 32
0
Try editing your AndroidManifest.xml to look like this
<activity
android:name=".YOURACTIVITYNAME"
android:screenOrientation="landscape" />

sijeesh
- 298
- 1
- 15
0
In your AndroidManifest file, try typing in the following code:
android:configChanges="keyboard|orientation|keyboardHidden|screenSize"
android:screenOrientation="landscape"
example:
<activity
android:name="com.gaspar.slinfilipino.Quiz"
android:label="@string/title_activity_quiz"
android:configChanges="keyboard|orientation|keyboardHidden|screenSize"
android:screenOrientation="landscape"
android:parentActivityName="com.gaspar.slinfilipino.SignLanguageMenu" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.gaspar.slinfilipino.SignLanguageMenu" />
</activity>

user2680756
- 3
- 1
- 5