Android examples for Hardware:Sensor
get Applied Acceleration
//package com.java2s; import android.hardware.SensorManager; import android.util.Log; public class Main { public static double getAppliedAcceleration(float[] values) { float x = values[SensorManager.DATA_X]; float y = values[SensorManager.DATA_Y]; float z = values[SensorManager.DATA_Z]; Log.e("log.e", " " + x + " " + y + " " + z); double appliedAcceleration = 0.0f; appliedAcceleration += Math.pow(x / SensorManager.GRAVITY_EARTH, 2.0);/* www.jav a2 s . c om*/ appliedAcceleration += Math.pow(y / SensorManager.GRAVITY_EARTH, 2.0); appliedAcceleration += Math.pow(z / SensorManager.GRAVITY_EARTH, 2.0); appliedAcceleration = Math.sqrt(appliedAcceleration); return appliedAcceleration; } }