I'm trying to force the "portrait" mode for my application because my application is absolutely not designed for the "landscape" mode.
After reading some forums, I added these lines in my manifest file:
<application android:debuggable="true" android:icon="@drawable/icon" android:label="@string/app_name" android:screenOrientation="portrait">
But it doesn't work on my device (HTC Desire). It switches from "portrait" lo "landscape", ignoring the lines from the manifest file.
After more forums reading, I tried to add this in my manifest file:
<application android:debuggable="true" android:icon="@drawable/icon" android:label="@string/app_name" android:configChanges="orientation" android:screenOrientation="portrait">
and this function in my activity class:
public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); }
But again, no luck.
Android Settings Start by going to Settings => Display and locate the "Device rotation" setting. On my personal cell phone, tapping this will reveal two options: "Rotate the contents of the screen," and "Stay in portrait view."
Swipe down from the top-right corner of your screen to open Control Center. Tap the Portrait Orientation Lock button to make sure that it's off.
On an iPhone without a Home button, swipe down from the top-right corner of the screen instead. Here, tap on the rotation lock icon (which looks like a lock with a circular arrow) to turn it on or off.
Don't apply the orientation to the application element, instead you should apply the attribute to the activity element, and you must also set configChanges
as noted below.
Example:
<activity android:screenOrientation="portrait" android:configChanges="orientation|keyboardHidden"> </activity>
This is applied in the manifest file AndroidManifest.xml
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With