Example usage for android.hardware SensorManager SENSOR_STATUS_ACCURACY_MEDIUM

List of usage examples for android.hardware SensorManager SENSOR_STATUS_ACCURACY_MEDIUM

Introduction

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

Prototype

int SENSOR_STATUS_ACCURACY_MEDIUM

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

Click Source Link

Document

This sensor is reporting data with an average level of accuracy, calibration with the environment may improve the readings

Usage

From source file:com.piser.apps.AppFive.CamActivity.java

@Override
public ArchitectView.SensorAccuracyChangeListener getSensorAccuracyListener() {
    return new ArchitectView.SensorAccuracyChangeListener() {
        @Override/*  ww  w.  j a va 2  s.  c  om*/
        public void onCompassAccuracyChanged(int accuracy) {
            /* UNRELIABLE = 0, LOW = 1, MEDIUM = 2, HIGH = 3 */
            if (accuracy < SensorManager.SENSOR_STATUS_ACCURACY_MEDIUM && CamActivity.this != null
                    && !CamActivity.this.isFinishing() && System.currentTimeMillis()
                            - CamActivity.this.lastCalibrationToastShownTimeMillis > 5 * 1000) {
                Toast.makeText(CamActivity.this, R.string.compass_accuracy_low, Toast.LENGTH_LONG).show();
                CamActivity.this.lastCalibrationToastShownTimeMillis = System.currentTimeMillis();
            }
        }
    };
}

From source file:com.spectralinsights.locar.SampleCamActivity.java

@Override
public SensorAccuracyChangeListener getSensorAccuracyListener() {
    return new SensorAccuracyChangeListener() {
        @Override//  w  w w. j a v  a2  s  .co  m
        public void onCompassAccuracyChanged(int accuracy) {
            /* UNRELIABLE = 0, LOW = 1, MEDIUM = 2, HIGH = 3 */
            if (accuracy < SensorManager.SENSOR_STATUS_ACCURACY_MEDIUM && SampleCamActivity.this != null
                    && !SampleCamActivity.this.isFinishing() && System.currentTimeMillis()
                            - SampleCamActivity.this.lastCalibrationToastShownTimeMillis > 5 * 1000) {
                Toast.makeText(SampleCamActivity.this, R.string.compass_accuracy_low, Toast.LENGTH_LONG).show();
                SampleCamActivity.this.lastCalibrationToastShownTimeMillis = System.currentTimeMillis();
            }
        }
    };
}

From source file:com.ap.jesus.migsv2.CamActivity.java

@Override
public SensorAccuracyChangeListener getSensorAccuracyListener() {
    return new SensorAccuracyChangeListener() {
        @Override/*from w w  w  .  j  a  v a2s.c o  m*/
        public void onCompassAccuracyChanged(int accuracy) {
            /* UNRELIABLE = 0, LOW = 1, MEDIUM = 2, HIGH = 3 */
            if (accuracy < SensorManager.SENSOR_STATUS_ACCURACY_MEDIUM && CamActivity.this != null
                    && !CamActivity.this.isFinishing() && System.currentTimeMillis()
                            - CamActivity.this.lastCalibrationToastShownTimeMillis > 5 * 1000) {
                Toast.makeText(CamActivity.this, R.string.compass_accuracy_low, Toast.LENGTH_LONG).show();
                CamActivity.this.lastCalibrationToastShownTimeMillis = System.currentTimeMillis();
            }
        }
    };
}

From source file:com.cyberprism.libin.artourist.ARActivity.java

@Override
public ArchitectView.SensorAccuracyChangeListener getSensorAccuracyListener() {
    return new ArchitectView.SensorAccuracyChangeListener() {
        @Override/*from  w ww  . j av a  2 s .  c o  m*/
        public void onCompassAccuracyChanged(int accuracy) {
            /* UNRELIABLE = 0, LOW = 1, MEDIUM = 2, HIGH = 3 */
            if (accuracy < SensorManager.SENSOR_STATUS_ACCURACY_MEDIUM && ARActivity.this != null
                    && !ARActivity.this.isFinishing() && System.currentTimeMillis()
                            - ARActivity.this.lastCalibrationToastShownTimeMillis > 5 * 1000) {
                Toast.makeText(ARActivity.this, "Low accuracy", Toast.LENGTH_LONG).show();
                ARActivity.this.lastCalibrationToastShownTimeMillis = System.currentTimeMillis();
            }
        }
    };
}

From source file:org.apache.cordova.devicemotion.AccelListener.java

/**
 * Start listening for acceleration sensor.
 *
 * @return          status of listener/*from  w w w .  j av  a 2  s.  c om*/
*/
private int start() {
    // If already starting or running, then restart timeout and return
    if ((this.status == AccelListener.RUNNING) || (this.status == AccelListener.STARTING)) {
        startTimeout();
        return this.status;
    }

    this.setStatus(AccelListener.STARTING);

    // Get accelerometer from sensor manager
    List<Sensor> list = this.sensorManager.getSensorList(Sensor.TYPE_ACCELEROMETER);

    // If found, then register as listener
    if ((list != null) && (list.size() > 0)) {
        this.mSensor = list.get(0);
        if (this.sensorManager.registerListener(this, this.mSensor, SensorManager.SENSOR_DELAY_UI)) {
            this.setStatus(AccelListener.STARTING);
            // CB-11531: Mark accuracy as 'reliable' - this is complementary to
            // setting it to 'unreliable' 'stop' method
            this.accuracy = SensorManager.SENSOR_STATUS_ACCURACY_MEDIUM;
        } else {
            this.setStatus(AccelListener.ERROR_FAILED_TO_START);
            this.fail(AccelListener.ERROR_FAILED_TO_START, "Device sensor returned an error.");
            return this.status;
        }
        ;

    } else {
        this.setStatus(AccelListener.ERROR_FAILED_TO_START);
        this.fail(AccelListener.ERROR_FAILED_TO_START,
                "No sensors found to register accelerometer listening to.");
        return this.status;
    }

    startTimeout();

    return this.status;
}

From source file:com.polyvi.xface.extension.XAccelerometerExt.java

@Override
public void onSensorChanged(SensorEvent event) {
    // Only look at accelerometer events
    if (event.sensor.getType() != Sensor.TYPE_ACCELEROMETER) {
        return;/*from  w  w w .  j  a  va  2s . co m*/
    }

    // If not running, then just return
    if (mStatus == STOPPED) {
        return;
    }
    mStatus = RUNNING;
    if (mAccuracy >= SensorManager.SENSOR_STATUS_ACCURACY_MEDIUM) {
        mTimestamp = System.currentTimeMillis();
        mX = event.values[0];
        mY = event.values[1];
        mZ = event.values[2];

        win();
    }
}

From source file:ch.bfh.sensordataprocessor.sensor.SensorDisplayFragment.java

/**
 * @see android.hardware.SensorEventListener#onAccuracyChanged(android.hardware.Sensor, int)
 *//*w  ww.  j a  v a 2 s  .c  om*/
@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
    switch (accuracy) {
    case SensorManager.SENSOR_STATUS_ACCURACY_HIGH:
        this.accuracy.setText("SENSOR_STATUS_ACCURACY_HIGH");
        break;
    case SensorManager.SENSOR_STATUS_ACCURACY_MEDIUM:
        this.accuracy.setText("SENSOR_STATUS_ACCURACY_MEDIUM");
        break;
    case SensorManager.SENSOR_STATUS_ACCURACY_LOW:
        this.accuracy.setText("SENSOR_STATUS_ACCURACY_LOW");
        break;
    case SensorManager.SENSOR_STATUS_UNRELIABLE:
        this.accuracy.setText("SENSOR_STATUS_UNRELIABLE");
        break;
    }
}

From source file:org.dartlang.phonegap.barometer.BarometerListener.java

/**
 * Sensor listener event.// ww w . jav  a 2 s . com
 *
 * @param SensorEvent event
 */
public void onSensorChanged(SensorEvent event) {
    // Only look at barometer events
    if (event.sensor.getType() != Sensor.TYPE_PRESSURE) {
        return;
    }

    // If not running, then just return
    if (this.status == BarometerListener.STOPPED) {
        return;
    }
    this.setStatus(BarometerListener.RUNNING);

    if (this.accuracy >= SensorManager.SENSOR_STATUS_ACCURACY_MEDIUM) {

        // Save time that event was received
        this.timestamp = System.currentTimeMillis();
        this.pressure = event.values[0];

        this.win();
    }
}

From source file:com.android.plugins.GyroscopeListener.java

/**
 * Sensor listener event.// www  .  jav  a  2 s .co m
 *
 * @param SensorEvent event
 */
public void onSensorChanged(SensorEvent event) {
    // Only look at gyroscope events
    if (event.sensor.getType() != Sensor.TYPE_GYROSCOPE) {
        return;
    }

    // If not running, then just return
    if (this.status == GyroscopeListener.STOPPED) {
        return;
    }
    this.setStatus(GyroscopeListener.RUNNING);

    if (this.accuracy >= SensorManager.SENSOR_STATUS_ACCURACY_MEDIUM) {

        // Save time that event was received
        this.timestamp = System.currentTimeMillis();
        this.x = event.values[0];
        this.y = event.values[1];
        this.z = event.values[2];

        this.win();
    }
}

From source file:org.dartlang.phonegap.thermometer.ThermometerListener.java

/**
 * Sensor listener event.//  w ww .ja  va  2s. c  om
 *
 * @param SensorEvent event
 */
public void onSensorChanged(SensorEvent event) {
    // Only look at thermometer events
    if (event.sensor.getType() != Sensor.TYPE_AMBIENT_TEMPERATURE) {
        return;
    }

    // If not running, then just return
    if (this.status == ThermometerListener.STOPPED) {
        return;
    }
    this.setStatus(ThermometerListener.RUNNING);

    if (this.accuracy >= SensorManager.SENSOR_STATUS_ACCURACY_MEDIUM) {

        // Save time that event was received
        this.timestamp = System.currentTimeMillis();
        this.temperature = event.values[0];

        this.win();
    }
}