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
2010-08-23 14:09:45
I can get a `Sensor` object, but how can I get a reading?http://developer.android.com/reference/android/hardware/Sensor.html
Computerish
2010-08-24 20:39:29
getResolution() or getPower() method.
radek-k
2010-08-25 08:37:55
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
2010-09-04 22:45:50
+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
2010-09-19 17:15:56