Reverse Screen Orientation and Compass

alfcen

Well-Known Member
Licensed User
Longtime User
Sorry, if I overlooked something.

Is there any means of checking whether a screen orientation is reverse or 'normal'?
If possible without the Phone library (my users dislike this permission).
This seems important as the compass is 180 degrees off in reverse mode.

It also appears as if phones and tablets use a different angle of origin which is 90 degrees offset.
This is no major issue, though.

Thanks for reading
 

warwound

Expert
Licensed User
Longtime User
I think you'll find your problem is more a device related problem than a programming problem.

I've found that some devices have a buggy implementation of sensors and will give unpredictable orientations - cheap chinese tablets seem to be big offenders here.
Other device's work perfectly - it's all dependant on the manufacturer's implementation of orientation detection in their firmware.

Martin.
 
Upvote 0

alfcen

Well-Known Member
Licensed User
Longtime User
@warwound
Thanks a lot for your thoughts. It's not a Chinese tablet, but an "NEC Lifetouch".
The orientation sensors are quite accurate. Naturally, when you rotate the tablet, say,
from portrait to reverse portrait, then North and South swap, which does make sense.

That's why I thought it would be useful to be able to determine the present screen
orientation programmatically and add an appropriate offset to the sensor's value.

Phone1.SetScreenOrientation(7/8) invoke reverse mode, in that, analog to this something
like a "GetScreenOrientation" command could perhaps be implemented, provided the O/S
follows device rotations.

Cheers

Robert
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
You can use this code:

Erel,

On my Samsung Ace phone it always seem to return 0?

does it only work when allowing landscape & portrait? (this test if forced to portrait)
 
Last edited:
Upvote 0

sorex

Expert
Licensed User
Longtime User
ok, it seems that it gets set at a valid rotation only. It's not changing when rotating the phone in a forced orientation.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…