Get Android rotation angle in x-axis

15,451

There is azimuth, pitch and roll available to you. Not sure which one relates to your "x-axis" but I think its azimuth.

Time for helpful links:

  1. http://www.workingfromhere.com/blog/2009/03/30/orientation-sensor-tips-in-android/
  2. http://marakana.com/forums/android/examples/43.html
  3. http://marakana.com/static/tutorials/SensorDemo.zip
Share:
15,451
Admin
Author by

Admin

Updated on June 24, 2022

Comments

  • Admin
    Admin about 2 years

    I'm experimenting with some Android functions. Right now, I'm trying to get the rotation angle of the device, so when I show a happy face bitmap on a canvas, it always looks "straight".

    All I would need for this, is to get the x-axis rotation angle (I guess) but I can't find how to achieve it. Hope you can help me. Thank you.

  • Admin
    Admin almost 12 years
    It works perfectly! azimuth is a little slow, but does the job! Thanks a lot. Just one thing that worries me, as it says that SensorListener and SENSOR_ORIENTATION are now deprecated... This means there is a new way to do so, right?
  • Admin
    Admin almost 12 years
    I must add. With Marakana's example in mind, i modified it slightly to use SensorEventListener and Sensor.TYPE_ORIENTATION instead. The response is quite faster, and now the only deprecated object is Sensor.TYPE_ORIENTATION. I'll leave it this way for now, since the new "solution" is quite more complex and gives the same result. Thank you for all!
  • MonoThreaded
    MonoThreaded about 9 years
    Please note SENSOR_ORIENTATION is deprecated