The coordinate system sensor in Android does not change, does it?

I read in many places, for example: One screen deserves another , which: "The coordinate system of the sensor, the API used for the natural orientation of the device does not change as the device moves and matches the OpenGL coordinate system."

Now I get the same thing as this image: enter image description here

I do not understand: If the coordinate system does not change, if I rotate the phone (always with the screen facing the user), gravity should be applied on the Y axis, always. It should change the axis only if I put the phone in a position where the screen is no longer facing the user, and does not lie on the table where gravity should be applied on the Z axis.

What is wrong with my understanding?

Thanks! Guillermo.

+4
source share
1 answer

The axis is replaced when the screen orientation of the device changes. For the article you indicated:

However, the Android sensor APIs determine the coordinate space of the sensor relative to the top and side of the device, rather than the short and long sides. When the system reorients the screen in response to holding the phone laterally, the coordinate system of the sensor no longer aligns with the coordinate system of the screens, and you get unexpected rotations on the display of your application.

To access unoccupied values, use indexes 3, 4, and 5 in the [] values ​​if you want, otherwise some of the sentences mentioned in the same article work very well!

+2
source

Source: https://habr.com/ru/post/1396610/


All Articles