Gentlemen,
Up until now I have been using SensorEventListener.onSensorChanged
(SensorEvent evt) to obtain data values from the on board sensors (G1)
whenever a sensor event occurs (snippet below). However, what I really
want to be able to do is read the values of all the sensors (i.e.
Sensor.TYPE_ORIENTATION, Sensor.TYPE_ACCELEROMETER and
Sensor.TYPE_MAGNETIC_FIELD) together at the same instant in time, or
near enough as the system will allow.
I'm probably being thick but does anyone know whether there a way of
reading the sensor values directly without having to use/wait for
onSensorChanged() ?
Many thanks in advance,
B.
----------
Snippet - currently using onSensorChanged(SensorEvent evt):
SensorManager sman = (SensorManager) getSystemService
(Context.SENSOR_SERVICE);
List<Sensor> accelerometer = sman.getSensorList
(Sensor.TYPE_ACCELEROMETER);
Sensor myAccelerometer = accelelerometer.get(0);
sman.registerListener(new SensorEventListener() {
public void onAccuracyChanged(Sensor arg0, int
arg1) {
}
public void onSensorChanged(SensorEvent evt) {
// read new sensor values
accelTextView.setText("X-accel: " +
evt.values[0] + "\n" + "Y-
accel: "
+ evt.values[1] + "\n"
+ "Z-accel: " + evt.values[2]);
accelTextView.invalidate();
// sleep for a bit
try {
Thread.sleep(10);
} catch (Exception ex) {
accelTextView.setText("Erk!");
}
}
}, myAccelerometer, SensorManager.SENSOR_DELAY_UI);
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---