Example usage for android.hardware SensorManager DATA_Z

List of usage examples for android.hardware SensorManager DATA_Z

Introduction

In this page you can find the example usage for android.hardware SensorManager DATA_Z.

Prototype

int DATA_Z

To view the source code for android.hardware SensorManager DATA_Z.

Click Source Link

Document

Index of the Z value in the array returned by android.hardware.SensorListener#onSensorChanged

Usage

From source file:Main.java

public static boolean move(float[] values, float[] preAccelerometerValues) {
    float difx = Math.abs(values[SensorManager.DATA_X]);
    float dify = Math.abs(values[SensorManager.DATA_Y]);
    float difz = Math.abs(values[SensorManager.DATA_Z]);
    Log.e("log.e val = ", " " + difx + " " + dify + " " + difz);

    float difx1 = Math.abs(preAccelerometerValues[SensorManager.DATA_X]);
    float dify1 = Math.abs(preAccelerometerValues[SensorManager.DATA_Y]);
    float difz1 = Math.abs(preAccelerometerValues[SensorManager.DATA_Z]);
    Log.e("log.e pre = ", " " + difx1 + " " + dify1 + " " + difz1);

    float difx2 = Math.abs(values[SensorManager.DATA_X] - preAccelerometerValues[SensorManager.DATA_X]);
    float dify2 = Math.abs(values[SensorManager.DATA_Y] - preAccelerometerValues[SensorManager.DATA_Y]);
    float difz2 = Math.abs(values[SensorManager.DATA_Z] - preAccelerometerValues[SensorManager.DATA_Z]);
    Log.e("log.e  dif = ", " " + difx2 + " " + dify2 + " " + difz2);

    if (checkMove(values[SensorManager.DATA_X], preAccelerometerValues[SensorManager.DATA_X])
            || checkMove(values[SensorManager.DATA_Y], preAccelerometerValues[SensorManager.DATA_Y])
            || checkMove(values[SensorManager.DATA_Z], preAccelerometerValues[SensorManager.DATA_Z])) {
        return true;
    }//from   w  ww.  j a  v  a2 s. c  o  m
    return false;
}

From source file:edu.cens.loci.sensors.AccelerometerHandler.java

private synchronized void onSensorChangedLocked(SensorEvent event) {

    if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {

        mFlag = true;/*from  www.j  a  v a  2  s .co m*/

        if (mIsOn)
            mMagArr.addMagnitude(event.values[SensorManager.DATA_X], event.values[SensorManager.DATA_Y],
                    event.values[SensorManager.DATA_Z], event.accuracy);

        //mXArr.add(event.values[SensorManager.DATA_X]);
        //mYArr.add(event.values[SensorManager.DATA_Y]);
        //mZArr.add(event.values[SensorManager.DATA_Z]);
    }
}