コード例 #1
0
  public boolean hasCompass() {
    boolean compass = false;

    SensorManager sm = sensorHelper.getSensorManager();
    if (sm != null) {
      compass = sm.getDefaultSensor(Sensor.TYPE_ORIENTATION) != null;
    }

    return compass;
  }
コード例 #2
0
  public boolean getHasCompass() {
    boolean compass = false;

    SensorManager sensorManager = TiSensorHelper.getSensorManager();
    if (sensorManager != null) {
      compass = sensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION) != null;
    } else {
      compass =
          TiSensorHelper.hasDefaultSensor(geolocationModule.getActivity(), Sensor.TYPE_ORIENTATION);
    }

    return compass;
  }