Java Code Examples for android.hardware.Sensor#TYPE_GYROSCOPE
The following examples show how to use
android.hardware.Sensor#TYPE_GYROSCOPE .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MynaService.java From Myna with Apache License 2.0 | 8 votes |
@Override public void onSensorChanged(SensorEvent event) { if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) { updateSensorData(latestSampledData.accelerate, event); } else if (event.sensor.getType() == Sensor.TYPE_GYROSCOPE) { updateSensorData(latestSampledData.gyroscope, event); } else if (event.sensor.getType() == Sensor.TYPE_GRAVITY) { updateSensorData(latestSampledData.gravity, event); } else if (event.sensor.getType() == Sensor.TYPE_LIGHT) { latestSampledData.light = event.values[0]; } else if (event.sensor.getType() == Sensor.TYPE_PRESSURE) { latestSampledData.pressure = event.values[0]; } else if (event.sensor.getType() == Sensor.TYPE_AMBIENT_TEMPERATURE) { latestSampledData.temperature = event.values[0]; } else if (event.sensor.getType() == Sensor.TYPE_MAGNETIC_FIELD) { updateSensorData(latestSampledData.magnetic, event); } else if (event.sensor.getType() == Sensor.TYPE_GAME_ROTATION_VECTOR) { updateSensorData(latestSampledData.game_rotation_vector, event); } }
Example 2
Source File: ControllerFragment.java From Bluefruit_LE_Connect_Android_V2 with MIT License | 6 votes |
@Override public void onSensorChanged(SensorEvent event) { int sensorType = event.sensor.getType(); if (sensorType == Sensor.TYPE_ACCELEROMETER) { mSensorData[kSensorType_Accelerometer].values = event.values; updateOrientation(); // orientation depends on Accelerometer and Magnetometer mControllerAdapter.notifySensorChanged(kSensorType_Accelerometer); mControllerAdapter.notifySensorChanged(kSensorType_Quaternion); } else if (sensorType == Sensor.TYPE_GYROSCOPE) { mSensorData[kSensorType_Gyroscope].values = event.values; mControllerAdapter.notifySensorChanged(kSensorType_Gyroscope); } else if (sensorType == Sensor.TYPE_MAGNETIC_FIELD) { mSensorData[kSensorType_Magnetometer].values = event.values; updateOrientation(); // orientation depends on Accelerometer and Magnetometer mControllerAdapter.notifySensorChanged(kSensorType_Magnetometer); mControllerAdapter.notifySensorChanged(kSensorType_Quaternion); } }
Example 3
Source File: MainActivity.java From Wrox-ProfessionalAndroid-4E with Apache License 2.0 | 6 votes |
private void listing16_13() { // Listing 16-13: Calculating an orientation change using the gyroscope Sensor final float nanosecondsPerSecond = 1.0f / 100000000.0f; final float[] angle = new float[3]; SensorEventListener myGyroListener = new SensorEventListener() { public void onSensorChanged(SensorEvent sensorEvent) { if (lastTime != 0) { final float dT = (sensorEvent.timestamp - lastTime) * nanosecondsPerSecond; angle[0] += sensorEvent.values[0] * dT; angle[1] += sensorEvent.values[1] * dT; angle[2] += sensorEvent.values[2] * dT; } lastTime = sensorEvent.timestamp; } public void onAccuracyChanged(Sensor sensor, int accuracy) { } }; SensorManager sm = (SensorManager) getSystemService(Context.SENSOR_SERVICE); int sensorType = Sensor.TYPE_GYROSCOPE; sm.registerListener(myGyroListener, sm.getDefaultSensor(sensorType), SensorManager.SENSOR_DELAY_NORMAL); }
Example 4
Source File: DataManager.java From ibm-wearables-android-sdk with Apache License 2.0 | 6 votes |
/** * register the default sensor of specific type * @param type sensor id */ private void registerSensor(int type){ Sensor defaultSensor = sensorManager.getDefaultSensor(type); //set normalization factor if (type == Sensor.TYPE_ACCELEROMETER){ gestureDataHolder.allowSensorDataCollection(type); //normalize to range form -2 to 2 gestureDataHolder.setNormalizationFactor(type, 2 / defaultSensor.getMaximumRange()); } if (type == Sensor.TYPE_GYROSCOPE){ gestureDataHolder.allowSensorDataCollection(type); //from rad to deg gestureDataHolder.setNormalizationFactor(type, 57.2958); } sensorManager.registerListener(this, defaultSensor, SensorManager.SENSOR_DELAY_GAME); //sensorManager.registerListener(this, defaultSensor, SensorManager.SENSOR_DELAY_FASTEST); }
Example 5
Source File: DataManager.java From ibm-wearables-android-sdk with Apache License 2.0 | 6 votes |
/** * This method is called each time sensors data is changed * @param event sensor event */ @Override public void onSensorChanged(SensorEvent event) { final int sensorType = event.sensor.getType(); if (sensorType == Sensor.TYPE_ACCELEROMETER || sensorType == Sensor.TYPE_GYROSCOPE){ //add the event for future sending gestureDataHolder.addSensorData(event); if (gestureDataHolder.isHasDataToSend()){ sendNextGestureData(); } } else if (sensorType == Sensor.TYPE_HEART_RATE){ sendHeartRateData(event); } }
Example 6
Source File: WearAppService.java From DeviceConnect-Android with MIT License | 6 votes |
@Override public void onSensorChanged(final SensorEvent sensorEvent) { if (sensorEvent.sensor.getType() == Sensor.TYPE_ACCELEROMETER) { long time = System.currentTimeMillis(); long interval = time - mStartTime; mStartTime = time; float accelX = sensorEvent.values[0]; float accelY = sensorEvent.values[1]; float accelZ = sensorEvent.values[2]; final String data = accelX + "," + accelY + "," + accelZ + "," + mGyroX + "," + mGyroY + "," + mGyroZ + "," + interval; mExecutorService.execute(() -> { synchronized (mIds) { for (String id : mIds) { sendSensorEvent(data, id); } } }); } else if (sensorEvent.sensor.getType() == Sensor.TYPE_GYROSCOPE) { mGyroX = (float) (sensorEvent.values[0] * RAD2DEG); mGyroY = (float) (sensorEvent.values[1] * RAD2DEG); mGyroZ = (float) (sensorEvent.values[2] * RAD2DEG); } }
Example 7
Source File: IMUManager.java From mobile-ar-sensor-logger with GNU General Public License v3.0 | 5 votes |
@Override public final void onAccuracyChanged(Sensor sensor, int accuracy) { if (sensor.getType() == Sensor.TYPE_ACCELEROMETER) { linear_acc = accuracy; } else if (sensor.getType() == Sensor.TYPE_GYROSCOPE) { angular_acc = accuracy; } }
Example 8
Source File: MainActivity.java From XMouse with MIT License | 5 votes |
@Override public void onSensorChanged(SensorEvent sensorEvent) { if(sensorEvent.sensor.getType()==Sensor.TYPE_GYROSCOPE) { float gyroscopeX=sensorEvent.values[1]; float gyroscopeY=sensorEvent.values[0]; float gyroscopeZ=sensorEvent.values[2]; String cmd; Switch mouseSwitch=findViewById(R.id.mouseSwitch); if (mouseSwitch.isChecked()) { if (Math.abs(gyroscopeX) >= 2 || Math.abs(gyroscopeY) >= 2) { if (gyroscopeX < 0 || gyroscopeY < 0) { cmd = "xdotool mousemove_relative -- " + (gyroscopeX) * 5 + " " + (gyroscopeY) * 5; } else { cmd = "xdotool mousemove_relative " + (gyroscopeX) * 5 + " " + (gyroscopeY) * 5; } conn.executeShellCommand(cmd); } if (gyroscopeZ >= 3) { cmd = "xdotool click 4"; conn.executeShellCommand(cmd); } else if (gyroscopeZ <= -3) { cmd = "xdotool click 5"; conn.executeShellCommand(cmd); } } } }
Example 9
Source File: MainActivity.java From journaldev with MIT License | 5 votes |
public void gyroscopeSensorOnClick(View view) { if (checkSensorAvailability(Sensor.TYPE_GYROSCOPE)) { currentSensor = Sensor.TYPE_GYROSCOPE; } else { textView.setText("Gyroscope Sensor not available"); } }
Example 10
Source File: SensorUtil.java From Sensor-Disabler with MIT License | 4 votes |
public static String[] getLabelsForSensor(Context context, Sensor sensor) { String[] labels; switch (sensor.getType()) { case Sensor.TYPE_ACCELEROMETER: labels = context.getResources().getStringArray(R.array.accelerometer_values); break; case Sensor.TYPE_AMBIENT_TEMPERATURE: labels = context.getResources().getStringArray(R.array.ambient_temperature_values); break; case Sensor.TYPE_GAME_ROTATION_VECTOR: labels = context.getResources().getStringArray(R.array.game_rotation_vector_values); break; case Sensor.TYPE_GEOMAGNETIC_ROTATION_VECTOR: labels = context.getResources().getStringArray(R.array.rotation_vector_values); break; case Sensor.TYPE_GRAVITY: labels = context.getResources().getStringArray(R.array.gravity_values); break; case Sensor.TYPE_GYROSCOPE: labels = context.getResources().getStringArray(R.array.gyroscore_values); break; case Sensor.TYPE_GYROSCOPE_UNCALIBRATED: labels = context.getResources().getStringArray(R.array.gyroscore_uncalibrated_values); break; case Sensor.TYPE_HEART_RATE: labels = context.getResources().getStringArray(R.array.heart_rate_values); break; case Sensor.TYPE_LIGHT: labels = context.getResources().getStringArray(R.array.light_values); break; case Sensor.TYPE_LINEAR_ACCELERATION: labels = context.getResources().getStringArray(R.array.linear_acceleration_values); break; case Sensor.TYPE_MAGNETIC_FIELD: labels = context.getResources().getStringArray(R.array.magnetic_values); break; case Sensor.TYPE_MAGNETIC_FIELD_UNCALIBRATED: labels = context.getResources().getStringArray(R.array.magnetic_field_uncalibrated_values); break; case Sensor.TYPE_PRESSURE: labels = context.getResources().getStringArray(R.array.pressure_values); break; case Sensor.TYPE_PROXIMITY: labels = context.getResources().getStringArray(R.array.proximity_values); break; case Sensor.TYPE_RELATIVE_HUMIDITY: labels = context.getResources().getStringArray(R.array.relative_humidity_values); break; case Sensor.TYPE_ROTATION_VECTOR: labels = context.getResources().getStringArray(R.array.rotation_vector_values); break; case Sensor.TYPE_STEP_COUNTER: labels = context.getResources().getStringArray(R.array.step_counter_values); break; default: labels = new String[]{}; } return labels; }
Example 11
Source File: GyroscopeSensor.java From AcDisplay with GNU General Public License v2.0 | 4 votes |
@Override public int getType() { return Sensor.TYPE_GYROSCOPE; }
Example 12
Source File: DeviceSensors.java From 365browser with Apache License 2.0 | 4 votes |
@VisibleForTesting void sensorChanged(int type, float[] values) { switch (type) { case Sensor.TYPE_ACCELEROMETER: if (mDeviceMotionIsActive) { gotAccelerationIncludingGravity(values[0], values[1], values[2]); } if (mDeviceOrientationIsActiveWithBackupSensors) { getOrientationFromGeomagneticVectors(values, mMagneticFieldVector); } break; case Sensor.TYPE_LINEAR_ACCELERATION: if (mDeviceMotionIsActive) { gotAcceleration(values[0], values[1], values[2]); } break; case Sensor.TYPE_GYROSCOPE: if (mDeviceMotionIsActive) { gotRotationRate(values[0], values[1], values[2]); } break; case Sensor.TYPE_ROTATION_VECTOR: if (mDeviceOrientationAbsoluteIsActive) { convertRotationVectorToAngles(values, mRotationAngles); gotOrientationAbsolute( mRotationAngles[0], mRotationAngles[1], mRotationAngles[2]); } if (mDeviceOrientationIsActive && mDeviceOrientationSensors == DEVICE_ORIENTATION_SENSORS_B) { if (!mDeviceOrientationAbsoluteIsActive) { // only compute if not already computed for absolute orientation above. convertRotationVectorToAngles(values, mRotationAngles); } gotOrientation(mRotationAngles[0], mRotationAngles[1], mRotationAngles[2]); } break; case Sensor.TYPE_GAME_ROTATION_VECTOR: if (mDeviceOrientationIsActive) { convertRotationVectorToAngles(values, mRotationAngles); gotOrientation(mRotationAngles[0], mRotationAngles[1], mRotationAngles[2]); } break; case Sensor.TYPE_MAGNETIC_FIELD: if (mDeviceOrientationIsActiveWithBackupSensors) { if (mMagneticFieldVector == null) { mMagneticFieldVector = new float[3]; } System.arraycopy( values, 0, mMagneticFieldVector, 0, mMagneticFieldVector.length); } break; default: // Unexpected return; } }
Example 13
Source File: AndroidSensorsDriver.java From sensorhub with Mozilla Public License 2.0 | 4 votes |
@Override public void start() throws SensorException { // we call stop() to cleanup just in case we weren't properly stopped stop(); Context androidContext = config.androidContext; // create data interfaces for sensors this.sensorManager = (SensorManager)androidContext.getSystemService(Context.SENSOR_SERVICE); List<Sensor> deviceSensors = sensorManager.getSensorList(Sensor.TYPE_ALL); for (Sensor sensor: deviceSensors) { log.debug("Detected sensor " + sensor.getName()); switch (sensor.getType()) { case Sensor.TYPE_ACCELEROMETER: if (config.activateAccelerometer) useSensor(new AndroidAcceleroOutput(this, sensorManager, sensor), sensor); break; case Sensor.TYPE_GYROSCOPE: if (config.activateGyrometer) useSensor(new AndroidGyroOutput(this, sensorManager, sensor), sensor); break; case Sensor.TYPE_MAGNETIC_FIELD: if (config.activateMagnetometer) useSensor(new AndroidMagnetoOutput(this, sensorManager, sensor), sensor); break; case Sensor.TYPE_ROTATION_VECTOR: if (config.activateOrientationQuat) useSensor(new AndroidOrientationQuatOutput(this, sensorManager, sensor), sensor); if (config.activateOrientationEuler) useSensor(new AndroidOrientationEulerOutput(this, sensorManager, sensor), sensor); break; } } // create data interfaces for location providers if (androidContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_LOCATION)) { this.locationManager = (LocationManager)androidContext.getSystemService(Context.LOCATION_SERVICE); List<String> locProviders = locationManager.getAllProviders(); for (String provName: locProviders) { log.debug("Detected location provider " + provName); LocationProvider locProvider = locationManager.getProvider(provName); // keep only GPS for now if ( (locProvider.requiresSatellite() && config.activateGpsLocation) || (locProvider.requiresNetwork() && config.activateNetworkLocation)) useLocationProvider(new AndroidLocationOutput(this, locationManager, locProvider), locProvider); } } // create data interfaces for cameras if (androidContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA)) createCameraOutputs(androidContext); // init all outputs for (ISensorDataInterface o: this.getAllOutputs().values()) ((IAndroidOutput)o).init(); // update sensorml description updateSensorDescription(); }
Example 14
Source File: SKAbstractNativeSensorModule.java From SensingKit-Android with GNU Lesser General Public License v3.0 | 4 votes |
@SuppressLint("InlinedApi") // There is a check in STEP_DETECTOR and STEP_COUNTER private static int getSensorType(SKSensorModuleType sensorType) throws SKException{ switch (sensorType) { case ACCELEROMETER: return Sensor.TYPE_ACCELEROMETER; case GRAVITY: return Sensor.TYPE_GRAVITY; case LINEAR_ACCELERATION: return Sensor.TYPE_LINEAR_ACCELERATION; case GYROSCOPE: return Sensor.TYPE_GYROSCOPE; case ROTATION: return Sensor.TYPE_ROTATION_VECTOR; case MAGNETOMETER: return Sensor.TYPE_MAGNETIC_FIELD; case AMBIENT_TEMPERATURE: return Sensor.TYPE_AMBIENT_TEMPERATURE; case STEP_DETECTOR: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { return Sensor.TYPE_STEP_DETECTOR; } else { throw new SKException(TAG, "STEP_DETECTOR requires Android KitKat or greater.", SKExceptionErrorCode.UNKNOWN_ERROR); } case STEP_COUNTER: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { return Sensor.TYPE_STEP_COUNTER; } else { throw new SKException(TAG, "STEP_COUNTER requires Android KitKat or greater.", SKExceptionErrorCode.UNKNOWN_ERROR); } case LIGHT: return Sensor.TYPE_LIGHT; case LOCATION: case ACTIVITY: case BATTERY: throw new SKException(TAG, "Not a native SensorModule.", SKExceptionErrorCode.UNKNOWN_ERROR); default: throw new SKException(TAG, "Unknown SensorModule", SKExceptionErrorCode.UNKNOWN_ERROR); } }
Example 15
Source File: MainActivity.java From journaldev with MIT License | 4 votes |
@Override public void onSensorChanged(SensorEvent event) { if (event.sensor.getType() == currentSensor) { if (currentSensor == Sensor.TYPE_LIGHT) { float valueZ = event.values[0]; textView.setText("Brightness " + valueZ); } else if (currentSensor == Sensor.TYPE_PROXIMITY) { float distance = event.values[0]; textView.setText("Proximity " + distance); } else if (currentSensor == Sensor.TYPE_STEP_DETECTOR) { float steps = event.values[0]; textView.setText("Steps : " + steps); } else if (currentSensor == Sensor.TYPE_ACCELEROMETER) { float x = event.values[0]; float y = event.values[1]; float z = event.values[2]; long curTime = System.currentTimeMillis(); if ((curTime - lastUpdate) > 100) { long diffTime = (curTime - lastUpdate); lastUpdate = curTime; float speed = Math.abs(x + y + z - last_x - last_y - last_z) / diffTime * 10000; if (speed > SHAKE_THRESHOLD) { Toast.makeText(getApplicationContext(), "Your phone just shook", Toast.LENGTH_LONG).show(); } last_x = x; last_y = y; last_z = z; } } else if (currentSensor == Sensor.TYPE_GYROSCOPE) { if (event.values[2] > 0.5f) { textView.setText("Anti Clock"); } else if (event.values[2] < -0.5f) { textView.setText("Clock"); } } else if (currentSensor == Sensor.TYPE_AMBIENT_TEMPERATURE) { textView.setText("Ambient Temp in Celsius :" + event.values[0]); } } }
Example 16
Source File: GyroHelper.java From libcommon with Apache License 2.0 | 4 votes |
/** * センサーの値が変化した時のコールバック * @param event */ @Override public void onSensorChanged(final SensorEvent event) { if (DEBUG) Log.v(TAG, "onSensorChanged:" + event); final float[] values = event.values; final int type = event.sensor.getType(); switch (type) { case Sensor.TYPE_MAGNETIC_FIELD: // 磁気センサー synchronized (mSensorSync) { // ハイパスフィルターを通して取得 // alpha=t/(t+dt), dt≒20msec@SENSOR_DELAY_GAME, tはローパスフィルタの時定数(t=80) highPassFilter(mMagnetValues, values, 0.8f); System.arraycopy(values, 0, mMagnetValues, 0, 3); // 磁気センサーの値と重力センサーの値から方位を計算 SensorManager.getRotationMatrix(mRotateMatrix, mInclinationMatrix, mGravityValues, mMagnetValues); getOrientation(mRotateMatrix, mAzimuthValues); mAzimuthValues[0] *= TO_DEGREE; mAzimuthValues[1] *= TO_DEGREE; mAzimuthValues[2] *= TO_DEGREE; } break; case Sensor.TYPE_GRAVITY: // 重力センサー synchronized (mSensorSync) { System.arraycopy(values, 0, mGravityValues, 0, 3); } break; case Sensor.TYPE_ACCELEROMETER: // 加速度センサー synchronized (mSensorSync) { System.arraycopy(values, 0, mAccelValues, 0, 3); System.arraycopy(values, 0, mGravityValues, 0, 3); // 重力センサーが無い時は加速度センサーで代用 } break; case Sensor.TYPE_GYROSCOPE: // ジャイロセンサー synchronized (mSensorSync) { System.arraycopy(values, 0, mGyroValues, 0, 3); } break; default: if (DEBUG) Log.v(TAG, "onSensorChanged:" + String.format(Locale.US, "その他%d(%f,%f,%f)", type, values[0], values[1], values[2])); break; } }
Example 17
Source File: SensorUtil.java From Sensor-Disabler with MIT License | 4 votes |
@Nullable public static String getHumanStringType(Sensor sensor) { switch (sensor.getType()) { case Sensor.TYPE_ACCELEROMETER: return "Accelerometer"; case Sensor.TYPE_AMBIENT_TEMPERATURE: return "Ambient Temperature"; case Sensor.TYPE_GAME_ROTATION_VECTOR: return "Game Rotation Vector"; case Sensor.TYPE_GEOMAGNETIC_ROTATION_VECTOR: return "Geomagnetic Rotation Vector"; case Sensor.TYPE_GRAVITY: return "Gravity"; case Sensor.TYPE_GYROSCOPE: return "Gyroscope"; case Sensor.TYPE_GYROSCOPE_UNCALIBRATED: return "Gyroscope (Uncalibrated)"; case Sensor.TYPE_HEART_RATE: return "Heart Rate"; case Sensor.TYPE_LIGHT: return "Light"; case Sensor.TYPE_LINEAR_ACCELERATION: return "Linear Acceleration"; case Sensor.TYPE_MAGNETIC_FIELD: return "Magnetic Field"; case Sensor.TYPE_MAGNETIC_FIELD_UNCALIBRATED: return "Magnetic Field (Uncalibrated)"; case Sensor.TYPE_PRESSURE: return "Pressure"; case Sensor.TYPE_PROXIMITY: return "Proximity"; case Sensor.TYPE_RELATIVE_HUMIDITY: return "Relative Humidity"; case Sensor.TYPE_ROTATION_VECTOR: return "Rotation Vector"; case Sensor.TYPE_SIGNIFICANT_MOTION: return "Significant Motion"; case Sensor.TYPE_STEP_COUNTER: return "Step Counter"; case Sensor.TYPE_STEP_DETECTOR: return "Step Detector"; case Sensor.TYPE_ORIENTATION: return "Orientation"; case Sensor.TYPE_TEMPERATURE: return "Temperature"; } return null; }
Example 18
Source File: XSensorManager.java From XPrivacy with GNU General Public License v3.0 | 4 votes |
@Override protected void before(XParam param) throws Throwable { switch (mMethod) { case getDefaultSensor: if (isRestricted(param)) param.setResult(null); else if (param.args.length > 0 && param.args[0] instanceof Integer) if (isRestricted(param, (Integer) param.args[0])) param.setResult(null); break; case getSensorList: if (isRestricted(param)) param.setResult(new ArrayList<Sensor>()); else if (param.args.length > 0 && param.args[0] instanceof Integer) if (isRestricted(param, (Integer) param.args[0])) param.setResult(new ArrayList<Sensor>()); break; case registerListener: if (param.args.length > 2 && param.args[1] instanceof Sensor && param.args[2] instanceof Integer) { int type = ((Sensor) param.args[1]).getType(); if (type == Sensor.TYPE_GYROSCOPE || type == Sensor.TYPE_GYROSCOPE_UNCALIBRATED) { int rateUs = (Integer) param.args[2]; // http://developer.android.com/guide/topics/sensors/sensors_overview.html if (rateUs == SensorManager.SENSOR_DELAY_NORMAL) return; // 200,000 us else if (rateUs == SensorManager.SENSOR_DELAY_UI) return; // 60,000 us else if (rateUs == SensorManager.SENSOR_DELAY_GAME) return; // 20,000 us else if (rateUs == SensorManager.SENSOR_DELAY_FASTEST) ; // 0 us if (rateUs < cMaxRateUs) // 10,000 us if (isRestricted(param)) param.args[2] = cMaxRateUs; } } break; } }
Example 19
Source File: GyroscopeUpdatesProvider.java From PrivacyStreams with Apache License 2.0 | 4 votes |
GyroscopeUpdatesProvider(int sensorDelay) { super(Sensor.TYPE_GYROSCOPE, sensorDelay); }
Example 20
Source File: SensorDetailFragment.java From AndroidDemoProjects with Apache License 2.0 | 4 votes |
private void populateTypeField( int type ) { if( type == 0 || mTypeRow == null || mType == null ) return; String typeName; switch( type ) { case Sensor.TYPE_ACCELEROMETER: { typeName = "Accelerometer"; break; } case Sensor.TYPE_AMBIENT_TEMPERATURE: { typeName = "Ambient Temperature"; break; } case Sensor.TYPE_GAME_ROTATION_VECTOR: { typeName = "Game Rotation Vector"; break; } case Sensor.TYPE_GEOMAGNETIC_ROTATION_VECTOR: { typeName = "Geomagnetic Rotation Vector"; break; } case Sensor.TYPE_GRAVITY: { typeName = "Gravity"; break; } case Sensor.TYPE_GYROSCOPE: { typeName = "Gyroscope"; break; } case Sensor.TYPE_GYROSCOPE_UNCALIBRATED: { typeName = "Uncalibrated Gyroscope"; break; } case Sensor.TYPE_LIGHT: { typeName = "Light"; break; } case Sensor.TYPE_LINEAR_ACCELERATION: { typeName = "Linear Acceleration"; break; } case Sensor.TYPE_MAGNETIC_FIELD: { typeName = "Magnetic Field"; break; } case Sensor.TYPE_MAGNETIC_FIELD_UNCALIBRATED: { typeName = "Uncalibrated Magnetic Field"; break; } case Sensor.TYPE_PRESSURE: { typeName = "Pressure"; break; } case Sensor.TYPE_PROXIMITY: { typeName = "Proximity"; break; } case Sensor.TYPE_RELATIVE_HUMIDITY: { typeName = "Relative Humidity"; break; } case Sensor.TYPE_ROTATION_VECTOR: { typeName = "Rotation Vector"; break; } case Sensor.TYPE_SIGNIFICANT_MOTION: { typeName = "Significant Motion"; break; } case Sensor.TYPE_STEP_COUNTER: { typeName = "Step Counter"; break; } case Sensor.TYPE_STEP_DETECTOR: { typeName = "Step Detector"; break; } default: { typeName = "Other"; } } mType.setText( typeName ); mTypeRow.setVisibility( View.VISIBLE ); }