Is there a way to retrieve multiple sensor data in Android

Can you try something like this: private SensorManager mSensorManager; private SensorEventListener mSensorListener; //// mSensorManager = (SensorManager) this .getSystemService(Context.SENSOR_SERVICE); mSensorListener = new SensorEventListener() { @Override public void onAccuracyChanged(Sensor arg0, int arg1) { } @Override public void onSensorChanged(SensorEvent event) { Sensor sensor = event.sensor; if (sensor.getType() == Sensor.TYPE_ACCELEROMETER) { //TODO: get values }else if (sensor.getType() == Sensor.TYPE_ORIENTATION) … Read more

iPhone Proximity Sensor

There is a public API for this. -[UIApplication setProximitySensingEnabled:(BOOL)] will turn the feature on. BTW, it doesn’t seem to be using the light sensor, because proximity sensing would tweak out in a dark room. However, the API call basically blanks the screen when you hold the phone up to your face. Not useful for interaction, … Read more

How should I calculate azimuth, pitch, orientation when my Android device isn’t flat?

When the device is not flat, you have to call remapCoordinateSystem(inR, AXIS_X, AXIS_Z, outR); before calling getOrientation. The azimuth returns by getOrientation is obtained by orthogonally project the device unit Y axis into the world East-North plane and then calculate the angle between the resulting projection vector and the North axis. Now we normally think … Read more

how to calculate phone’s movement in the vertical direction from rest?

If you integrate the acceleration twice you get position but the error is horrible. It is useless in practice. Here is an explanation why (Google Tech Talk) at 23:20. I highly recommend this video. Now, you do not need anything accurate and that is a different story. The linear acceleration is available after sensor fusion, … Read more

Smoothing data from a sensor

The simplest is to do a moving average of your data. That is, to keep an array of sensor data readings and average them. Something like this (pseudocode): data_X = [0,0,0,0,0]; function read_X () { data_X.delete_first_element(); data_X.push(get_sensor_data_X()); return average(data_X); } There is a trade-off when doing this. The larger the array you use, the smoother … Read more

Android TYPE_LINEAR_ACCELERATION sensor – what does it show?

Very interesting question!!!! I’m developing somethig similar to your application. What i found about TYPE_LINEAR_ACCELERATION isn’t happy for me. 1) TYPE_LINEAR_ACCELERATION, TYPE_GRAVITY, ecc are implemented only for Android 2.3 (and up) So i have Android 2.2 and i can’t test them. 2) TYPE_LINEAR_ACCELERATION isn’t so accurate as it would be, because there are some simple … Read more