2

I am unable to undertand and find out how to detect the change in orientation of android phone from horizontal to vertical position. Here i am not talking about orientation change between portrait or landscape. Example can be like i have phone in horizontal position lying on a floor and then i lift up to see the screen from front. So actually the phone had a transition from one axis to another.

Can i do it using Rotation Vector sensor?

Nelson Almendra
  • 784
  • 1
  • 9
  • 20
Wahib Ul Haq
  • 4,185
  • 3
  • 44
  • 41

2 Answers2

1

You will need the Gravity Sensor: http://developer.android.com/guide/topics/sensors/sensors_motion.html

In the absence of a Gravity Sensor you have to rely on Accelerometer and Gyroscope, I think.

Herrbert74
  • 2,578
  • 31
  • 51
  • Yes ! using gravity sensor worked for me. Gravity sensor shows change from 0 to +9 while moving phone from one position to another. Thanks ev1 :) – Wahib Ul Haq Jun 09 '13 at 21:51
1

Look at my answer to Android Compass that can Compensate for Tilt and Pitch. In the code that I posted, the variable m_pitch_radians will be zero when the phone is lying on the floor, and PI/2 (i.e. 90 degrees) when it's standing upright.

Community
  • 1
  • 1
Stochastically
  • 7,616
  • 5
  • 30
  • 58