android:screenOrientation="sensorPortrait" doesn't work on API +17 - android

I want my application to work in Portrait & reversePortrait mode .. In other words, I want it to work in portrait and make it rotatable 180 degrees!
I'm using the following code within <activity> tag of the MainActivity in the Manifest.
android:screenOrientation="sensorPortrait"
However, this seems to work only on Android 4.1.2 and backward.
It doesn't work on Android 4.2.2 and above!
I tried on different phones, the same result! How to solve it?

I'm aware of a typo error by Google that replaced sensorPortrait by sensorPortait at some point.
Not sure if that is your case, but depending on your targetApi, it might.
Use sensorPortait and see what happens at compilation.
This has been fixed in API 16.

Related

Forcing portrait orientation on Android stopped working after update to Lollipop, but only when debugging from Eclipse

I'm working on a libGDX application and based on this question I'm forcing portrait orientation in activity tag of AndroidManifest.xml like this:
android:screenOrientation="portrait"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
This used to work fine on my devices until my Samsung Galaxy S4 got upgraded to Lollipop (5.0.1) from KitKat. Now it doesn't work on this device, while still working on others (with lower Android versions). On the S4 it just displays the application in landscape, ignoring rotation.
I was looking for differences in the 5.0 API that could explain this, but couldn't find anything.
Edit: I've just tried exporting my app to .apk and it displayed properly. Previously I was running it from Eclipse debug mode. It shouldn't be hard to pinpoint the issue, but I don't have time to investigate it at the moment.
Edit2: I've just tried running it from Eclipse on a different machine, where I have API 21 (so Lollipop) and it worked. However my working .apk has been exported on another machine, where I have API 20. It's really puzzling me. Might be something related to Android plugin versions, but I'm not sure if I will be able to pinpoint it.
try
android:screenOrientation="sensorPortrait"
I am not sure what your API level. But there was a google bug around this issue, which was fixed by API 16. If you are using anything earlier and if above line does not work, try
android:screenOrientation="sensorPortait"
instead.

android:screenOrientation=“sensorPortrait" not valid?

I need to limit my app to displaying in portrait mode.
Using android:screenOrientation=“Portrait" works great but I'd like to have the display change to reverse portrait when the device is rotated.
Using android:screenOrientation="sensorPortrait" results in a compile error.
Funny thing though, if I use "sensorLandscape" instead it compiles fine but it's not what I need.
I'm using Eclipse v 3.7.2 with Android 2.3.3
Any ideas???
Thanks
Rob
Google has made a typo, use sensorPortait

Android Orientation phonegap version

I'm making an Android app using Eclipse, phonegap (version 2.1.0) and html5.
I'm encountering a problem with the orientation of the app. When I rotate the mobile, on landscape mode, the app crashes. I looked to the other posts and applied the methode that seems to work for others (e.g android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale") but the app continue to crash.
And when I try this : android:configChanges="orientation|keyboardHidden" , the app doesn't crash in landscape mode but don't come back to portait mode!
My minimum required version is android 2.3.3 for the app.
Does anyone have already encoutered this problem and solve it for Android 2.3.3? I'm kind lost and don't know what other solution to test.
Thanks
Kraken
UPDATE: Something I forgot to say is that I'm working only on the emulator. I don't have a device with android 2.3.3 so that I could test my app.
Make sure that for all of your activities you set at least the below code:
Do you have a splash screen maybe that doesnt have it or an admob or other advertisement view on it?
<activity android:name="main" android:launchMode="standard" android:configChanges="orientation|keyboardHidden"></activity>
Also make sure that you save your instance when rotating in your webview like described in this post: Android WebView: handling orientation changes
If it then still crashes please provide some log file to show the error it is having.

configChanges="orientation" doesn't trigger on Galaxy Nexus

Hello I have a strange bug, when I want to trigger the orientation change on the Galaxy Nexus(4.0.4), it simply doesn't jump into the onConfigurationChanged(Configuration) function.
On the HTC Desire(4.0.4) it works without any issues with the same code. And even on an emulator with 720p it works. I tried to update to Android 4.1, but I still have the same problem.
Does anyone have the same problems or any solutions?
I see both devices running Android 4.x, but try adding screenSize value as described in my earlier answer here.
In the manifest, int the <activity> tag, add android:configChanges="orientation". This tells the system that your activity will handle orientation changes by itself, hence the onConfigurationChanged() will be triggered.
screenSize flag on Android 4.X needed.
Try another android compiler builder.
If you have called setRequestedOrientation(..) in the activity before, the onConfigurationChanged(Configuration) will not be triggered by the system auto-detect of rotation.

Application crashed when orientation change

Actually my problem is the same as the question posted in :
the same problem
But there is no answer yet..
Here is the problem I got :
I've just built an application using sencha touch & phone gap. It runs well on my galaxy tab but when I rotate it to portrait or landscape, it is going crash.
I have added :
android:configChanges="orientation|keyboardHidden"
on my manifest file but it is still going crash when I rotate it.
I don't know how could this happen.
Could someone help me?
Note :
I'm using
- Galaxy tab
- Sencha-touch 1.1
- Phone gap 1.2
You should have
android:configChanges="keyboardHidden|orientation|screenLayout"
instead of
android:configChanges="orientation|keyboardHidden"
to your activity in the manifest
Might be a bit late... but since I've recently been trying this, I found that specifying
android:configChanges="orientation|screenSize|keyboardHidden"
works where as
android:configChanges="keyboardHidden|orientation|screenLayout"
does NOT.
I'm using cordova 2.0.0.

Categories

Resources