Code example for Sensor

Methods: getType

0
		} 
 
		public void onSensorChanged(SensorEvent event) {
			Sensor mySensor = event.sensor;
			 
			if (mySensor.getType() == Sensor.TYPE_ACCELEROMETER) {
			 
				xa = event.values[0];
				ya = event.values[1];
				za = event.values[2];
	 
				sensorRed   = (int)  Math.min( 255, Math.abs(-xa*255/10.0) ) ;
				sensorGreen = (int)  Math.min( 255, Math.abs(-ya*255/10.0) ) ;
				sensorBlue  = (int)  Math.min( 255, Math.abs(-za*255/10.0) ) ;
			} 
			 
			else if (mySensor.getType() == Sensor.TYPE_ORIENTATION) {
				sensorOrientation = event.values[0];
			} 
		} 
 
    }