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

Canonical way to obtain CDI managed bean instance: BeanManager#getReference() vs Context#get()

cdi managed-bean

I figured that there are two general ways to obtain an auto-created CDI managed bean instance via BeanManager when having solely a Bean<T> to start with (which is created based on Class<T&...

Making a query dynamically based on a date picker in PHP

php sql

I'm trying to show some data between 2 dates chosen by the user in a date picker but I didn't found a way to write the query right.,always got this error :

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.