Definition of android device natural orientation - android

I want to change the basic orientation of an android device. Curently its startup orientation is landscape, I need portrait.
I managed to modify the acceleration values so that the axis now point to where I want them to point to.
But the device seems to have its own definition of up and right. Now I have to change this.
Can someone tell me where this can be done? I guess there is a config file out there that I can't identify.
There are millions of hits searching for this problems. Unfortunately they all deal with java programming, not with OS code.

In your manifest file under activity tag that is on which screen you want to apply that orientation.
For portrait
android:screenOrientation="portrait"
For landscape
android:screenOrientation="landscape"

Add this lines of code in Androidmanifest.xml for the orientation
<activity android:name=".SomeActivity"
android:label="#string/app_name"
android:screenOrientation="landscape">

Related

SCREEN_ORIENTATION_PORTRAIT not working after installing the app

I have a problem to lock the orientation of my app in portrait mode. I added android:screenOrientation="portrait" and android:configChanges="orientation" to my Manifest. Moreover, I added setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) in the onCreate(...) of my MainActivity. The MainActivity is extended by AppCompatActivity. At any time, it works, so you never see your app in the landscape orientation, except when you install it for the first time on your device. Then it is possible to change between landscape and portrait orientation. Does anybody know why this happens? Thank you in advance.
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.

Android Studio - landscape only but still rotate

I want my android studio app to be landscape only, but to switch orientation when the phone is rotated.
This means that when u flip the phone 180°, it will still be landscape but will flip sides. Like the clash of clans game.
You should add the sensorLandscape screenOrientation tag to your activity in the android manifest file and you should be good to go.
android:screenOrientation="sensorLandscape"
Make sure to add this to all the activities that you want to have in landscape mode.
All you need is to go to your AndroidManifest.xml file and under each Activity add the screen orientation tag and set it to sensorLandscape. Make sure you do it for all the other activities if you want them to be in landscape too.
For Example :
<activity
android:name=".MainActivity"
android:label="#string/title_MainActivity"
android:screenOrientation="sensorLandscape">
</activity>

Unity3D application always launches with same orientation on Android, regardless of OS orientation

When I launches app, it always has same orientation.
After some seconds, maybe in splash scene, it turns to OS orientation.
I got that the orientation always 'Landscape Left' even if device was 'Landscape Right'.
That is my problem.
I expect that app launches so that it matches the orientation of os.
Not portrait or landscape problem, but 'Landscape Left' or 'Landscape Right' problem ;(
PlayerSettings like as bellow.
http://answers.unity3d.com/storage/temp/48453-orientation.png
I set 'Auto Rotation' and checked 'Landscape Right' and 'Landscape Left'.
http://answers.unity3d.com/storage/temp/48455-minsdk.png
And I also set min SDK api level 14.
I set screenOrientation="landscape" in AndroidManifest.xml
<activity android:name="myMainActivity" android:label="#string/app_name" android:theme="#android:style/Theme.Black.NoTitleBar.Fullscreen" android:icon="#drawable/app_icon" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:screenOrientation="landscape" android:launchMode="singleTop">
Im using Unity3d 4.6.6p1
Thanks ;)
You can use this to control the orientation in the device via Code Screen.orientation.
You only need to ask wich are the current orientation and channge it to the other if you need it.
Hope It'll be helpfull to you.

Layout doesn't rotate automatically

Hi I already made two XML layout file with same name, one in layout folder and the other in layout-land.
I already add the configChanges tag in Manifest, like this:
<activity
android:name=".Main"
android:label="#string/title_activity_main"
android:configChanges="orientation|screenSize" >
...
</activity>
The layout won't change automatically after rotating my phone.
But when I started the app in Landscape orientation, it will use the layout-land xml and keep using it even after I rotated my phone into portrait. So, there is no error in the landscape code.
I'm using Android 4.1.2 for testing. Is this the problem?
Or do I need to add some code in the Activity class?
Thanks
[Update]
I tried this in freshly-made project. But the problem still the same
Remove android:configChanges="orientation".
Using this attribute means that you will handle the rotation yourself, but you want the OS to handle it for you.

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?
You could try using
android:screenOrientation="user"
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.
you can add android:screenOrientation="user" and make sure there is no SCREEN_ORIENTATION_SENSOR in the java code or manifest.

Categories

Resources