/** Disable orientation updates */ public void disableCompass() { if (mSensorListener != null) { mSensorListener.stopListening(); } // Reset values mSensorListener = null; mAzimuth = Float.NaN; // Update the screen to see changes take effect if (mMapView != null) { mMapView.postInvalidate(); } }
/** * Enable orientation sensor (compass) updates and show a compass on the map. You will want to * call enableCompass() probably from your Activity's Activity.onResume() method, to enable the * features of this overlay. Remember to call the corresponding disableCompass() in your * Activity's Activity.onPause() method to turn off updates when in the background. */ public boolean enableCompass() { boolean result = true; if (mSensorListener == null) { mSensorListener = new SensorEventListenerProxy(mSensorManager); result = mSensorListener.startListening( this, Sensor.TYPE_ORIENTATION, SensorManager.SENSOR_DELAY_UI); } // Update the screen to see changes take effect if (mMapView != null) { mMapView.postInvalidate(); } return result; }