Configuring screen orientation on Android - android

I am developing an Android app with Cordova, I use this line in AndroidManifest.xml in order to force a landscape:
android:screenOrientation="landscape"
And it works, but the problem when you flip your phone over 180* the landscape will stay reverse, like this:

Make it android:screenOrientation="sensorLandscape" instead.

Related

Samsung Tab S2 not respecting manifest screenOrientation

I have an Activity that is meant to be displayed in landscape. Ideally I want to support either direction of landscape. In my manifest I've set this on my Activity:
android:screenOrientation="sensorLandscape"
Which has worked fine in all my experience in the past. But this device seems to decide sometimes that portrait orientation is allowed. It will rotate to all 4 orientations (landscape/reverseLandscape, and portrait/reversePortrait).
If I set it like this:
android:screenOrientation="landscape"
it works correctly. Also if I disable screen rotation then it works correctly. However both of these options leave me with no reverseLandscape.
I've also tried requesting the orientation to be set in Java code:
setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
This does not seem to make any difference in the behavior.
Is this a known issue on Samsung devices? and is there any workaround to get the device to respect my sensorLandscape orientation setting?

How to remember last screen orientation setting in android

I have a android 6.0.1 tablet. My activity is here using following orientation settings:
<activity
android:name=".MainActivity"
android:screenOrientation="sensorLandscape"
android:label="#string/app_name"
android:windowSoftInputMode="adjustResize|stateHidden"
android:configChanges="keyboardHidden|orientation|screenSize|uiMode">
When i turn tablet into 180 degree application activity rotate but problem is that when i turn on and off screen using power button on tablet while tablet is in 180 degree, application took few second to rotate. This was not happing in older android version. Is there any android activity setting which i can use to keep remember last screen orientation and keep it same either tablet screen turn off and on ?
Simply use this in onCreate of your activity to disable rotation of activity when screen turn on and off:
((KeyguardManager)getSystemService("keyguard")).newKeyguardLock("keyguard").disableKeyguard();

Tablet devices loading wrong orientation

My app only uses one page which is the main activity and in the manifest it is set not to allow rotation hence the orientation stays the same wether or not you rotate the device. however on tablets when a user is in landscape orientation and runs the app. the app loads the default orientation (Portrait) but in a landscape view instead and im seeing only half the screen.
help.
This is part of my activity in manifest i use nosensor to disable rotation.
<activity
android:name="com.paul.xicon.MainActivity"
android:windowSoftInputMode="adjustPan"
android:label="#string/app_name"
android:screenOrientation="nosensor">
I'm not sure how are you disabling the screen rotation. But this should work just fine in your activity tag of manifest.
android:screenOrientation="landscape" (disables the screen-rotation & restricts to landscape mode)
or,
android:screenOrientation="portrait" (disables the screen-rotation & restricts to portrait mode)

My tablet's orientation is 180 degrees (upside is down)?

When developing the app it looks great on my virtual devices.
But when trying it on my real tablet it displays the whole app upside down!
Can I change the orientation by 180 degrees somewhere in the android settings?
Can I change my code slightly to display the app in 180 degrees?
Please note that I am using api8 (android 2.2)
You can set the screen orientation of the activity in the AndroidManifest.xml file
e.g
<activity
.
.
android:screenOrientation="reverseLandscape"
/>
You can use other options see the documentation
I realize the question is about 2.2, however this valuable piece of code (2.3+) handles both orientations of landscape inside your manifest:
android:screenOrientation="sensorLandscape"

froyo's universal rotation and my landscape only app

My app is set in landscape only mode thanks to an attribute in my manifest file, but with froyo came universal rotation and a problem. It will force the screen to landscape but if the user is holding the phone upside down my app will appear upside down. Is there a way for me to set my app to only rotate when the user has their phone orientented in both landscape positions?
I have one app in landscape mode and put in manifest this attribute:
android:screenOrientation="landscape"
Put this into activity and works fine for me (Froyo 2.2 Nexus One)
... By the way sorry for my english

Categories

Resources