Java tutorial
//package com.java2s; //License from project: Apache License import android.hardware.Sensor; public class Main { private static String UNKNOWN = ""; @SuppressWarnings("deprecation") public static String getSensorTypeStr(int type) { switch (type) { case Sensor.TYPE_ALL://-1 return "TYPE_ALL"; //Accelerometer sensor type case Sensor.TYPE_ACCELEROMETER://1 return "TYPE_ACCELEROMETER"; //Magnetic field sensor type case Sensor.TYPE_MAGNETIC_FIELD://2 return "TYPE_MAGNETIC_FIELD"; //Orientation sensor type case Sensor.TYPE_ORIENTATION://3 return "TYPE_ORIENTATION"; //Gyroscope sensor type case Sensor.TYPE_GYROSCOPE://4 return "TYPE_GYROSCOPE"; //Light sensor type case Sensor.TYPE_LIGHT://5 return "TYPE_LIGHT"; //Pressure sensor type case Sensor.TYPE_PRESSURE://6 return "TYPE_PRESSURE"; //Temperature sensor type case Sensor.TYPE_TEMPERATURE://7 return "TYPE_TEMPERATURE"; //Proximity sensor type case Sensor.TYPE_PROXIMITY://8 return "TYPE_PROXIMITY"; //Gravity sensor type case Sensor.TYPE_GRAVITY://9 return "TYPE_GRAVITY"; //Linear acceleration sensor type case Sensor.TYPE_LINEAR_ACCELERATION://10 return "TYPE_LINEAR_ACCELERATION"; //Rotation vector sensor type case Sensor.TYPE_ROTATION_VECTOR://11 return "TYPE_ROTATION_VECTOR"; //Relative humidity sensor type case Sensor.TYPE_RELATIVE_HUMIDITY://12 return "TYPE_RELATIVE_HUMIDITY"; //Ambient temperature sensor type case Sensor.TYPE_AMBIENT_TEMPERATURE://13 return "TYPE_AMBIENT_TEMPERATURE"; //Uncalibrated magnetic field sensor type case Sensor.TYPE_MAGNETIC_FIELD_UNCALIBRATED://14 return "TYPE_MAGNETIC_FIELD_UNCALIBRATED"; //Uncalibrated rotation vector sensor type case Sensor.TYPE_GAME_ROTATION_VECTOR://15 return "TYPE_GAME_ROTATION_VECTOR"; //Uncalibreted gyroscope sensor type case Sensor.TYPE_GYROSCOPE_UNCALIBRATED://16 return "TYPE_GYROSCOPE_UNCALIBRATED"; //Significant motion trigger sensor case Sensor.TYPE_SIGNIFICANT_MOTION://17 return "TYPE_SIGNIFICANT_MOTION"; //Step detector sensor case Sensor.TYPE_STEP_DETECTOR://18 return "TYPE_STEP_DETECTOR"; //Step counter sensor case Sensor.TYPE_STEP_COUNTER://19 return "TYPE_STEP_COUNTER"; //Geo-magnetic rotation vector case Sensor.TYPE_GEOMAGNETIC_ROTATION_VECTOR://20 return "TYPE_GEOMAGNETIC_ROTATION_VECTOR"; //Heart rate monitor case Sensor.TYPE_HEART_RATE://21 return "TYPE_HEART_RATE"; default: return UNKNOWN; } } }