/**
   * Enable receiving orientation updates from the provided IOrientationProvider and show a compass
   * on the map. You will likely want to call enableCompass() 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 (mIsCompassEnabled) mOrientationProvider.stopOrientationProvider();

    result = mOrientationProvider.startOrientationProvider(this);
    mIsCompassEnabled = result;

    // Update the screen to see changes take effect
    if (mMapView != null) {
      this.invalidateCompass();
    }

    return result;
  }
  protected void setOrientationProvider(IOrientationProvider orientationProvider) {
    if (orientationProvider == null)
      throw new RuntimeException(
          "You must pass an IOrientationProvider to setOrientationProvider()");

    if (mOrientationProvider != null) mOrientationProvider.stopOrientationProvider();

    mOrientationProvider = orientationProvider;
  }
  /** Disable orientation updates */
  public void disableCompass() {
    mIsCompassEnabled = false;

    if (mOrientationProvider != null) {
      mOrientationProvider.stopOrientationProvider();
    }

    // Reset values
    mAzimuth = Float.NaN;

    // Update the screen to see changes take effect
    if (mMapView != null) {
      this.invalidateCompass();
    }
  }