Example usage for android.hardware Sensor TYPE_LIGHT

List of usage examples for android.hardware Sensor TYPE_LIGHT

Introduction

In this page you can find the example usage for android.hardware Sensor TYPE_LIGHT.

Prototype

int TYPE_LIGHT

To view the source code for android.hardware Sensor TYPE_LIGHT.

Click Source Link

Document

A constant describing a light sensor type.

Usage

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;// ww w  .ja va  2s .  c o  m

    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;
    }
}