Tutorial by Examples

Retrieving sensor information from the onboard sensors: public class MainActivity extends Activity implements SensorEventListener { private SensorManager mSensorManager; private Sensor accelerometer; private Sensor gyroscope; float[] accelerometerData = new float[3]; f...
The sensor values returned by Android are with respective to the phone's coordinate system (e.g. +Y points towards the top of the phone). We can transform these sensor values into a world coordinate system (e.g. +Y points towards magnetic North, tangential to the ground) using the sensor managers ro...
Add the following code to the onCreate()/onResume() method: SensorManager sensorManager; Sensor mAccelerometer; final float movementThreshold = 0.5f; // You may have to change this value. boolean isMoving = false; float[] prevValues = {1.0f, 1.0f, 1.0f}; float[] currValues = new float[3]; ...

Page 1 of 1