Reputation: 4415
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?
Upvotes: 2
Views: 3230
Reputation: 7846
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.
Upvotes: 1
Reputation: 2725
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.
Upvotes: 1