Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
public class MainActivity extends AppCompatActivity implements SensorEventListener // class decl
SensorManager manager = (SensorManager) getSystemService(SENSOR_SERVICE); // oncreate
manager.registerListener(this, manager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), // oncreate or onresume
manager.unregisterListener(this); // ondestory or onpause
public void onSensorChanged(SensorEvent event) {
Log.i("UpDown", "values = " + event.values[0] + " " + event.values[1] + " " + event.values[2]);
public void onAccuracyChanged(Sensor sensor, int accuracy) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.