Why TYPE_ORIENTATION is deprecated?

7,284 views
Skip to first unread message

Victor Surfer

unread,
Nov 22, 2011, 4:02:00 AM11/22/11
to android-platform
I find the TYPE_ORIENTATIN is deprecated in SDK2.3.4,
 
 

public static final int TYPE_ORIENTATION

Since: API Level 3

This constant is deprecated.
use SensorManager.getOrientation() instead.

 
 
 
 
Why it is deprecated? Does orientation be got still through orientation sensor?
 
 
Thanks,
Victor
 
 

Chinmay V S

unread,
Nov 22, 2011, 4:13:31 AM11/22/11
to android-...@googlegroups.com
The earlier method to query orientation was full of pitfalls for the app-developer. Hence, SENSOR_TYPE_ORIENTATION has been deprecated in favour of android.view.Display.getRotation()

Here's why:
http://android-developers.blogspot.com/2010/09/one-screen-turn-deserves-another.html


Chinmay V S

unread,
Nov 22, 2011, 4:22:28 AM11/22/11
to android-...@googlegroups.com
Also to get the exact values of azimuth, pitch and roll use SensorManager.getOrientation() instead. The SensorManager.getOrientation() method requires a rotation-matrix to transform the values properly.

Victor Surfer

unread,
Nov 22, 2011, 6:42:40 AM11/22/11
to android-...@googlegroups.com
Hi Chinmay,
Thanks for your kindly pointer.
Does orientation be got through accelerometer or orientation sensor or others?
--
You received this message because you are subscribed to the Google Groups "android-platform" group.
To post to this group, send email to android-...@googlegroups.com.
To unsubscribe from this group, send email to android-platfo...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-platform?hl=en.

Chinmay V S

unread,
Nov 22, 2011, 6:59:27 AM11/22/11
to android-...@googlegroups.com
Usually there is no "orientation-sensor" hardware.
A combination of accelerometer(for pitch, roll) & compass (for azimuth)
is presented as orientation to the framework by the sensor-HAL.

A quick overview of sensors:
http://thecodeartist.blogspot.com/2010/12/sensors-on-android-gingerbread.html

- CVS
Reply all
Reply to author
Forward
0 new messages