コード例 #1
0
ファイル: CgeoApplication.java プロジェクト: schwabe/cgeo
  @Override
  public void onCreate() {
    try {
      final ViewConfiguration config = ViewConfiguration.get(this);
      final Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
      menuKeyField.setAccessible(true);
      menuKeyField.setBoolean(config, false);
    } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException ignored) {
    }

    // Set language to English if the user decided so.
    initApplicationLocale(Settings.useEnglish());

    // ensure initialization of lists
    DataStore.getLists();

    // Check if Google Play services is available
    if (GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(this)
        == ConnectionResult.SUCCESS) {
      isGooglePlayServicesAvailable = true;
    }
    Log.i(
        "Google Play services are " + (isGooglePlayServicesAvailable ? "" : "not ") + "available");
    final Sensors sensors = Sensors.getInstance();
    sensors.setupGeoDataObservables(Settings.useGooglePlayServices(), Settings.useLowPowerMode());
    sensors.setupDirectionObservable(Settings.useLowPowerMode());

    // Attempt to acquire an initial location before any real activity happens.
    sensors
        .geoDataObservable(true)
        .subscribeOn(RxUtils.looperCallbacksScheduler)
        .first()
        .subscribe();
  }