p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2 (http://p2p.wrox.com/forumdisplay.php?f=432)
-   -   Sensor changes in 1.5? (http://p2p.wrox.com/showthread.php?t=74230)

peterkirn May 3rd, 2009 05:09 PM

Sensor changes in 1.5?
 
Looking through the official SDK documentation, I started to get quite confused about changes. (Side note: is there some way to see when looking at the reference documentation which change goes with which version of the SDK? So far it looks like ... no? Yipes!)

A number of the sensor techniques used in Chapter 10 then will become deprecated, as near as I can tell. Specifically:

SensorListener: deprecated, replaced by SensorEventListener and (for orientation, at least) OrientationEventListener helper class

SENSOR_ORIENTATION is now all under the Sensor class?

I'm just trying to gradually port some sensor code to the 1.5 SDK. Think it may be time to root my phone rather than wait for Google, since testing sensors in an emulator isn't the same.

Any particular advice in making this change? Chapter 10 I think is one of the best chapters of this book, so of course it'd be great to update it with new code.

peterkirn May 3rd, 2009 05:35 PM

One other note re: sensors - I'm seeing values that appears to be swapped.

In chapter 10 (and, indeed, in Google's documentation), roll, pitch, and heading are:
roll = DATA_X
pitch = DATA_Y
heading = DATA_Z

Note that, if I'm reading the reference correctly, these may need to be swapped to values[3], [4], and [5] if you want them to persist between different orientations of the device. Irrespective of referring to them by int or name, though, in testing the app on the G1 / OS 1.1, I get:

heading = values[3] aka DATA_X
pitch = values[4] aka DATA_Y
roll = values[5] aka DATA_Z

Any idea what might account for this? Will this work across devices, or just the G1?

Maybe this is solved, though, by the new sensor API.


All times are GMT -4. The time now is 09:23 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.