tags:

views:

38

answers:

1

Now that SENSOR_ORIENTATION is deprecated, what's the best practice for obtaining compass heading? The old way was so simple.

A: 

SensorManager.getOrientation(float[] R, float[] values) is the standard API call to use since API level 3.

CodeFusionMobile
Yeah, I found that in the documentation. Two more questions: what do you initialize R and values to? Also, is there a way to get notifications, or is that whole working model deprecated?
Edward Falk
OK, found a good example in the source base. I won't copy it here, but if you browse the git repository for Android, look at the end of development/samples/Compass/src/com/example/android/compass/CompassActivity.java
Edward Falk
Notifications/events is a poor way to do sensors, which is why it's deprectated afaik. Every minor aspect change would trigger a multitude of events, essentially choking the UI thread with data.
CodeFusionMobile