Upside down on some tablets

Helihead

Member
Licensed User
Longtime User
This is probably something easy and obvious but I have searched and can't find it.

My screens display correctly on most devices but are upside down on some tablets. You can turn the tablets over and it works but it is awkward it you have cables connected to what we normally think of as the bottom. I also noticed that B4ABridge is upside down on those tablets as well.

Anyway to flip the Y axis or otherwise correct so it displays right side up to match other programs?
 

Helihead

Member
Licensed User
Longtime User
Do those tablets have G-sensors? i.e. If you rotate the tablet 90 degrees does the screen automatically change from portrait to landscape. As far as I am aware it is Android itself that determines the orientation of a displayed Activity.


Yes they do. All other programs are correctly displayed as you rotate from portrait to landscape.

Run b4ABridge and it will be upside down in portrait mode. Rotate the tablet 180 degrees and it will be correct. All other programs would respond to the 180 degree rotation but b4abridge does not. It just rotates around like a magazine going from upside down to right side up.

My program does the same. I purposefully restrict my program to portrait mode if that helps. B4aBridge is not limited to portrait mode only.
 
Last edited:

Helihead

Member
Licensed User
Longtime User
What happens if you rotate B4Bridge just 90 degrees to landcape orientation from when it is upside down in portrait orientation?

Ahh you may be onto something...

ON a normal phone or tablet going from portrait to landscape has B4ABridge rotating to those modes as expected.

On the tablets where it is upside down, it does not respond to rotating the tablet. It stays fixed in it's original position no matter how you turn the tablet.

On that same "Bad" tablet, run something like email or a game and it DOES respond to tablet rotation by switching from landscape to portrait and back. That confirms that it has the sensor.

Seems like on some tablets, B4ABridge (and my program written in B4A) can't detect the rotation.
 
Last edited:

Helihead

Member
Licensed User
Longtime User
Set the orientation attribute to: fullSensor

Instead of the default value ("unspecified").
<activity> | Android Developers

Trying to add to the manifest:
<activity
android:windowSoftInputMode="stateHidden"
android:launchMode="singleTop"
android:screenOrientation="fullSensor">
</activity>

I'm obviously putting this in the wrong place and keep getting "AndroidManifest.xml:9: error: Error: String types not allowed (at 'screenOrientation' with value 'fullSensor')."
 

Helihead

Member
Licensed User
Longtime User
You have to add that line in your code, look under "Project attributes" region.

Not trying to be dense but I have added it in the code under Module Attributes, Project Attributes, and Activity Regions and in the manifest editor.

It always says "Error description: Attribute not supported: screenorientation"

Tried it as :
#screenOrientation: fullSensor
#screenOrientation="fullSensor"
screenOrientation="fullSensor"

The online help for this is very vague for where to add and exact syntax.
 

Helihead

Member
Licensed User
Longtime User
Just do THIS no need to touch the manifest.

Copied yours EXACTLY and put it in a code region at the top of my program NOT in the manifest.

Still get "AndroidManifest.xml:22: error: Error: String types not allowed (at 'screenOrientation' with value 'fullSensor')."
 

Helihead

Member
Licensed User
Longtime User
Looks like I have 8. I will update tonight and retry.

Thanks for sticking with me.

Jeff
 

Helihead

Member
Licensed User
Longtime User
Upgraded SDK all the way to 15.

fullSensor works but it doesn't do what I need. I want to restrict my App to Portrait only but I want portrait to know which way is up.

Looking through the docs it seems that sensorPortrait would be the correct value so I can limit to Portrait only but it does use the sensor to determine the correct orientation (not upside down).

"portrait" works.
"fullSensor" works.
Problem is that "sensorPortrait" throws the same "string not allowed" error.


"sensorPortrait" Portrait orientation, but can be either normal or reverse portrait based on the device sensor. Added in API level 9.
 

Helihead

Member
Licensed User
Longtime User
Seems like an error in Android documentation: android - Error: String types not allowed (at 'screenOrientation' with value 'sensorPortait') - Stack Overflow

This mode is only supported on API level 16 (Android 4.1?).


I upgaded my sdk and selected version 17. Setting "sensorPortrait" now works although it is a little quirky.

On the phones that oriented correctly before, it still works correctly. I have portrait only (as I wanted) and it knows which way is up. Rotating the phones 180 degrees has the application respond and upright itself in the new portrait orientation.

On the tablets that were upside down before, it is limited to portrait only (as I wanted) and it is no longer upside down. It now finds the right side up no matter which of the two portrait modes you hold your tablet in. Much Better! Only odd thing is that on these tablets, it does not respond if you rotate the tablet 180 degrees after start up.

Example: Hold your tablet in portrait with connectors at the bottom. Start the app and it starts right side up. Hold your tablet in portrait mode with connectors at the top, start the app and it starts right side up. Start up in portrait mode with connectors on the bottom or the top and it starts the app rightside up. Now rotate the tablet 180 degrees and the app stays as it was and ends up upside down.

It's much better than the way it was as it always starts right side up now and at least follows rotation on most of the phones. Not perfect but good enough for me for now.

Thanks for your help!
 

Eric H

Active Member
Licensed User
Longtime User
I can't get sensorPortrait to work on my Samsung Galaxy S4.

I have tried typing this in the manifest:
B4X:
SetActivityAttribute(main,android:screenOrientation, "sensorPortrait")

and according to some other folks, Google misspelled sensorPortrait as sensorPortait (missing the "r" in portrait) so I have tried this as well but get an error (AndroidManifest.xml:17: error: Error: String types not allowed (at 'screenOrientation' with value 'sensorPortait').):
B4X:
SetActivityAttribute(main,android:screenOrientation, "sensorPortait")

I am using this line also in my manifest, since it has been mentioned that it requires version 16 or higher to work:
B4X:
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="18"/>

Any idea why?
 

Eric H

Active Member
Licensed User
Longtime User
Thanks Erel, I have tried that also and am referencing SDK 17 or 18, so like you said, it must not be supported on this device. Ty for your response :)

Edit: although, oddly enough, sensor portrait and reverse portrait both work using this app: https://play.google.com/store/apps/details?id=nl.fameit.rotate I bet he has written custom code that isn't based off from the standard android orientation controller.
 
Last edited:
Top