Example usage for android.hardware SensorManager SENSOR_STATUS_ACCURACY_HIGH

List of usage examples for android.hardware SensorManager SENSOR_STATUS_ACCURACY_HIGH

Introduction

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

Prototype

int SENSOR_STATUS_ACCURACY_HIGH

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

Click Source Link

Document

This sensor is reporting data with maximum accuracy

Usage

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

/**
 * @see android.hardware.SensorEventListener#onAccuracyChanged(android.hardware.Sensor, int)
 *///from  w  w  w  . j  a va2  s  . c o  m
@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:io.github.data4all.service.OrientationListener.java

@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {

    if (sensor.getType() == Sensor.TYPE_ACCELEROMETER) {
        if (accuracy < SensorManager.SENSOR_STATUS_ACCURACY_HIGH) {
            Log.d(TAG, "The sensor: " + sensor.getName() + " has now the accuracy of " + accuracy
                    + " it needs recalibration!");

            accOk = accuracy;//w  ww  .j  a v a  2 s  .com
        } else {

            Log.d(TAG, "The sensor: " + sensor.getName() + " has now the accuracy of " + accuracy
                    + " App ready to use!");
            accOk = accuracy;
        }
    }
    if (sensor.getType() == Sensor.TYPE_MAGNETIC_FIELD) {
        if (accuracy < SensorManager.SENSOR_STATUS_ACCURACY_HIGH) {
            Log.d(TAG, "The sensor: " + sensor.getName() + " has now the accuracy of " + accuracy
                    + " it needs recalibration!");

            magOk = accuracy;
        } else {

            Log.d(TAG, "The sensor: " + sensor.getName() + " has now the accuracy of " + accuracy
                    + " App ready to use!");
            magOk = accuracy;
        }
    }
    this.checkAccuracy();
    /*
     * Creates a new Intent containing a Uri object BROADCAST_ACTION is a
     * custom Intent action
     */

    final Intent localIntent = new Intent(BROADCAST_CAMERA)
            // Puts the status into the Intent
            .putExtra(INTENT_CAMERA_UPDATE, true);
    // Broadcasts the Intent to receivers in this app.
    LocalBroadcastManager.getInstance(this).sendBroadcast(localIntent);
}

From source file:com.cellbots.logger.LoggerActivity.java

private void updateSensorUi(int sensorType, int accuracy, float[] values) {
    // IMPORTANT: DO NOT UPDATE THE CONTENTS INSIDE A DRAWER IF IT IS BEING
    // ANIMATED VIA A CALL TO animateOpen/animateClose!!!
    // Updating anything inside will stop the animation from running.
    // Note that this does not seem to affect the animation if it had been
    // triggered by dragging the drawer instead of being called
    // programatically.
    if (mDataDrawer.isMoving()) {
        return;/*  w w w . j  a  v  a2  s.  c  o  m*/
    }
    TextView xTextView;
    TextView yTextView;
    TextView zTextView;
    if (sensorType == Sensor.TYPE_ACCELEROMETER) {
        xTextView = mAccelXTextView;
        yTextView = mAccelYTextView;
        zTextView = mAccelZTextView;
    } else if (sensorType == Sensor.TYPE_GYROSCOPE) {
        xTextView = mGyroXTextView;
        yTextView = mGyroYTextView;
        zTextView = mGyroZTextView;
    } else if (sensorType == Sensor.TYPE_MAGNETIC_FIELD) {
        xTextView = mMagXTextView;
        yTextView = mMagYTextView;
        zTextView = mMagZTextView;
    } else {
        return;
    }

    int textColor = Color.WHITE;
    String prefix = "";
    switch (accuracy) {
    case SensorManager.SENSOR_STATUS_ACCURACY_HIGH:
        prefix = "  ";
        break;
    case SensorManager.SENSOR_STATUS_ACCURACY_MEDIUM:
        prefix = "  *";
        break;
    case SensorManager.SENSOR_STATUS_ACCURACY_LOW:
        prefix = "  **";
        break;
    case SensorManager.SENSOR_STATUS_UNRELIABLE:
        prefix = "  ***";
        break;
    }

    xTextView.setTextColor(textColor);
    yTextView.setTextColor(textColor);
    zTextView.setTextColor(textColor);
    xTextView.setText(prefix + numberDisplayFormatter(values[0]));
    yTextView.setText(prefix + numberDisplayFormatter(values[1]));
    zTextView.setText(prefix + numberDisplayFormatter(values[2]));

}

From source file:com.example.sensingapp.SensingApp.java

public void onAccuracyChanged(Sensor sensor, int accuracy) {
    switch (sensor.getType()) {
    case Sensor.TYPE_ACCELEROMETER:
        m_sSensorAccuracy = "1,"; //Accl
        break;//  w  w  w.  j a v  a2 s.  com

    case Sensor.TYPE_LINEAR_ACCELERATION:
        m_sSensorAccuracy = "2,"; //LinearAccl
        break;

    case Sensor.TYPE_GYROSCOPE:
        m_sSensorAccuracy = "3,"; //Gyro
        break;

    case Sensor.TYPE_MAGNETIC_FIELD:
        m_sSensorAccuracy = "4,"; //Magnet
        break;

    case Sensor.TYPE_GRAVITY:
        m_sSensorAccuracy = "5,"; //Gravity      
        break;

    case Sensor.TYPE_PROXIMITY:
        m_sSensorAccuracy = "6,"; //Proxi
        break;

    case Sensor.TYPE_LIGHT:
        m_sSensorAccuracy = "7,"; //Light
        break;

    case Sensor.TYPE_PRESSURE:
        m_sSensorAccuracy = "8,"; //Barometer
        break;

    case Sensor.TYPE_RELATIVE_HUMIDITY:
        m_sSensorAccuracy = "9,"; //Humidity
        break;

    case Sensor.TYPE_AMBIENT_TEMPERATURE:
        m_sSensorAccuracy = "10,"; //Temperature
        break;

    default:
        m_sSensorAccuracy = "11,"; //Other
    }

    switch (accuracy) {
    case SensorManager.SENSOR_STATUS_ACCURACY_HIGH:
        m_sSensorAccuracy = m_sSensorAccuracy + "1,"; //H
        break;

    case SensorManager.SENSOR_STATUS_ACCURACY_MEDIUM:
        m_sSensorAccuracy = m_sSensorAccuracy + "2,"; //M
        break;

    case SensorManager.SENSOR_STATUS_ACCURACY_LOW:
        m_sSensorAccuracy = m_sSensorAccuracy + "3,"; //L
        break;

    case SensorManager.SENSOR_STATUS_UNRELIABLE:
        m_sSensorAccuracy = m_sSensorAccuracy + "4,"; //U
        break;
    }
}