views:

83

answers:

2

I'm working on adding a calibration feature to an accelerometer-driven game. For the calibration, I need a single value from the accelerometer. Should I register a listener, get the first value it gives me, and unregister it, or is there a better way to get just one value?

+1  A: 

This should help:

http://developer.android.com/reference/android/hardware/SensorManager.html#getSensorList%28int%29

You simply get sensors which you are interested in and read their values.

radek-k
I can get a `Sensor` object, but how can I get a reading?http://developer.android.com/reference/android/hardware/Sensor.html
Computerish
getResolution() or getPower() method.
radek-k
Neither of those return the sensor's value. getPower returns the number of milliamps the sensor is using and getResolution returns the sensors accuracy.
Computerish
+1  A: 

Basically there is no way to do get a single value as far as I can tell. What I ended up doing is putting in a variable called lastAccelValue and registering my Activity to listen for accelerometer updates at the slowest possible speed. Each new accelerometer value is stored to lastAccelValue.

Computerish