Get multiple sensor data at the same time in Android

I am now trying to create an app to monitoring the vibration. I use accelerometer to finish the job, when the recorded acceleration exceed certain threshold, I call it a trigger. When there's a trigger, I want to log the acceleration, magnetic field, light level data (from different sensors) at the trigger time to a file.

The problem now is that: I can get data from individual sensor, but couldn't figure out a way how to get the data from multiple sensors at the same time. For example: I can set a sensorlistener to monitoring the change of accelerometer, when I record the acceleration data, can I also get data from other sensors at exactly the same time?

Thanks in advance.


Yes you can do this as follows:

private SensorManager manager;
private SensorEventListener listener;

manager = (SensorManager) this.getSystemService(Context.SENSOR_SERVICE);
listener = new SensorEventListener() {
    public void onAccuracyChanged(Sensor arg0, int arg1) {

    public void onSensorChanged(SensorEvent event) {
        Sensor sensor = event.sensor;
        if (sensor.getType() == Sensor.TYPE_ACCELEROMETER) {
        else if (sensor.getType() == Sensor.TYPE_GYROSCOPE) {

manager.registerListener(listener, manager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_GAME);
manager.registerListener(listener, manager.getDefaultSensor(TYPE_GYROSCOPE), SensorManager.SENSOR_DELAY_GAME);

Need Your Help

I need populate a repeater with pseudo-related data

c# .net-3.5 controls repeater

Before I do this I figured I would ask if it was the best way. Each "Vendor" object has a "Bucket" object. In my repeater I need to display some properties from Vendor and some from Bucket, also some

Jqgrid default sorting doesn't work in Chrome

jquery google-chrome sorting jqgrid

In Firefox & IE, the listing display as expected and default sorting is fine. And No. column displaying from 1,2,3... in ascending order