1

I've scrounged the web in search of a good example or someone trying to attempt the same thing, but so far I haven't had much luck.

I am trying to get my Devices rotation angle (If you can imagine) starting at 180° (Flat).

As the user tilts the device left and right, the angle adjusts accordingly. And as it rotates I want to simply update a TextView.

I'm just lost as to what this evolves, some people suggest a gyroscope, accelerometer, even a magnometer, or a combination. I've gotten a few different sensors to work, but none of the examples I've followed accomplish what I want to achieve.

I don't want anything to do with 3D, just a plan rotation.

Can anybody forward me in the right director, or provide some information?

Thank you very much!

Loren Kuich
  • 573
  • 3
  • 10
  • 25

1 Answers1

2

You implement OrientationEventListener this will give you the device rotation. Portrait is 0 degree.

Hoan Nguyen
  • 18,033
  • 3
  • 50
  • 54
  • I don't want my devices orientation (Portrait or Landscape). I want the exact angle. Won't the OrientationEventListener wait for the Orientation to change? (Portrait or Landscape) – Loren Kuich Apr 01 '13 at 04:54
  • If you implement what I said above in onOrientationChanged(int orientation) give you the rotation angle. – Hoan Nguyen Apr 01 '13 at 04:57
  • Got it working, this blog post helped. http://android-er.blogspot.ca/2010/08/orientationeventlistener-detect.html Thank you! Just needed to know what to Google for. – Loren Kuich Apr 01 '13 at 05:28
  • @HoanNguyen thanks for your answer...How can get angle of proportion even when directly move device from Landscape to portrait or vise-versa...which is nothing but tilt angle....have any idea how can get it? – CoDe Apr 30 '14 at 09:33
  • @Shubh I have no idea what do you mean by angle of proportion. – Hoan Nguyen Apr 30 '14 at 18:12