Skip to content

Instantly share code, notes, and snippets.

@iewnait
Created March 21, 2012 23:19
Show Gist options
  • Save iewnait/2154078 to your computer and use it in GitHub Desktop.
Save iewnait/2154078 to your computer and use it in GitHub Desktop.
onSensorChanged() for MagnetometerDemo
@Override
public void onSensorChanged(SensorEvent event) {
switch (event.sensor.getType()) {
case Sensor.TYPE_ACCELEROMETER:
// We need both the acceleration and magnetometer data to determine
// compass rotation. Save these values.
mAccelerationVals = event.values.clone();
break;
case Sensor.TYPE_MAGNETIC_FIELD:
// We need both the acceleration and magnetometer data to determine
// compass rotation. Save these values.
mMagneticFieldVals = event.values.clone();
//more code here
break;
//more code here
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment