Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Registering Sensor for the Barometer Tutorial on the SSaurel's Channel
SensorManager sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
Sensor pressureSensor = sensorManager.getDefaultSensor(Sensor.TYPE_PRESSURE);
SensorEventListener sensorEventListener = new SensorEventListener() {
@Override
public void onSensorChanged(SensorEvent sensorEvent) {
float[] values = sensorEvent.values;
txt.setText(String.format("%.3f mbar", values[0]));
}
@Override
public void onAccuracyChanged(Sensor sensor, int i) {
}
};
sensorManager.registerListener(sensorEventListener, pressureSensor, SensorManager.SENSOR_DELAY_UI);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment