Java 类com.google.android.gms.location.LocationRequest 实例源码

项目:traffic-report-android    文件:MainActivity.java   
@Override
public void onConnected(@Nullable Bundle bundle) {
    //Make request to get the users location
    mLocationRequest = new LocationRequest();
    mLocationRequest.setInterval(1000);
    mLocationRequest.setFastestInterval(1000);
    mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
    if (ContextCompat.checkSelfPermission(this,
            android.Manifest.permission.ACCESS_FINE_LOCATION)
            == PackageManager.PERMISSION_GRANTED) {
        LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, this);
    }
    MapStateManager mapStateManager = new MapStateManager(this);
    mMap.setMapType(mapStateManager.getMapType());
    Log.i(TAG, "onConnected: Current location and saved maptype set!");
}
项目:react-native-location-switch    文件:LocationSwitch.java   
public void displayLocationSettingsRequest(final Activity activity) {
    GoogleApiClient googleApiClient = new GoogleApiClient.Builder(activity)
            .addApi(LocationServices.API).build();
    googleApiClient.connect();

    LocationRequest locationRequest = LocationRequest.create();
    locationRequest.setPriority(mAccuracy);
    locationRequest.setInterval(mInterval);
    locationRequest.setFastestInterval(mInterval / 2);

    LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder()
            .addLocationRequest(locationRequest);
    builder.setAlwaysShow(false);

    final PendingResult<LocationSettingsResult> result =
            LocationServices.SettingsApi.checkLocationSettings(googleApiClient, builder.build());
    result.setResultCallback(new LocationResultCallback(activity));
}
项目:ttnmapper_android_v2    文件:TTNMapperService.java   
@Override
    public void onConnected(@Nullable Bundle bundle) {
        Log.d(TAG, "Google API client connected");
//        String locationProvider = LocationManager.GPS_PROVIDER;
        mLocationRequest = new LocationRequest();
        mLocationRequest.setInterval(5000);
        mLocationRequest.setFastestInterval(500);
        mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);


        if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
            // We should have permission as we ask for it at startup.
        } else {
            LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, this);
        }
    }
项目:oma-riista-android    文件:LocationClient.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (servicesAvailable()) {
        mGoogleApiClient = new GoogleApiClient.Builder(getActivity())
                .addApi(LocationServices.API)
                .addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this)
                .build();

        mLocationRequest = LocationRequest.create();
        mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
        mLocationRequest.setInterval(UPDATE_INTERVAL_MS);
        mLocationRequest.setFastestInterval(FASTEST_UPDATE_INTEVAL_MS);
    }
}
项目:RxTask    文件:RxFusedLocationProviderClient.java   
@NonNull
@RequiresPermission(
        anyOf = {"android.permission.ACCESS_COARSE_LOCATION", "android.permission" +
                ".ACCESS_FINE_LOCATION"}
)
public Observable<LocationResult> requestLocationRequestUpdates(LocationRequest request) {
    return ObservableTask.create(callback -> {
        LocationCallback resultCallback = new LocationCallback() {
            @Override
            public void onLocationResult(LocationResult result) {
                super.onLocationResult(result);
                callback.onNext(result);
            }
        };
        callback.setDisposeListener(() -> client.removeLocationUpdates(resultCallback));
        return client.requestLocationUpdates(request, resultCallback, null);
    });
}
项目:GitHub    文件:MockLocationsActivity.java   
@Override
protected void onLocationPermissionGranted() {
    mockModeToggleButton.setChecked(true);

    final LocationRequest locationRequest = LocationRequest.create()
            .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY)
            .setInterval(2000);
    updatedLocationSubscription = locationProvider
            .getUpdatedLocation(locationRequest)
            .map(new LocationToStringFunc())
            .map(new Func1<String, String>() {
                int count = 0;

                @Override
                public String call(String s) {
                    return s + " " + count++;
                }
            })
            .subscribe(new DisplayTextOnViewAction(updatedLocationView));
}
项目:AlarmWithL-T    文件:SettingFragment.java   
@Override
public void onConnected(@Nullable Bundle bundle) {

    mRequest = LocationRequest.create();
    //TODO: 変数
    mRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY)
            .setFastestInterval(1000)
            .setInterval(3000);
    if (ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
        // TODO: Consider calling
        //    ActivityCompat#requestPermissions
        // here to request the missing permissions, and then overriding
        //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
        //                                          int[] grantResults)
        // to handle the case where the user grants the permission. See the documentation
        // for ActivityCompat#requestPermissions for more details.
        return;
    }
    LocationServices.FusedLocationApi.requestLocationUpdates(mClient, mRequest, this);

}
项目:android-ponewheel    文件:MainActivity.java   
private void startLocationScan() {

        RxLocation rxLocation = new RxLocation(this);

        LocationRequest locationRequest = LocationRequest.create()
                .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY)
                .setInterval(TimeUnit.SECONDS.toMillis(5));

        rxLocationObserver = rxLocation.location()
                .updates(locationRequest)
                .subscribeOn(Schedulers.io())
                .flatMap(location -> rxLocation.geocoding().fromLocation(location).toObservable())
                .observeOn(Schedulers.io())
                .subscribeWith(new DisposableObserver<Address>() {
                    @Override public void onNext(Address address) {

                        boolean isLocationsEnabled = App.INSTANCE.getSharedPreferences().isLocationsEnabled();
                        if (isLocationsEnabled) {
                            mOWDevice.setGpsLocation(address);
                        } else if (rxLocationObserver != null) {
                            rxLocationObserver.dispose();
                        }
                    }

                    @Override public void onError(Throwable e) {
                        Log.e(TAG, "onError: error retreiving location", e);
                    }

                    @Override public void onComplete() {
                        Log.d(TAG, "onComplete: ");
                    }
                });
    }
项目:PrivacyStreams    文件:GoogleLocationUpdatesProvider.java   
private void startLocationUpdate() {
    long fastInterval = interval / 2;

    LocationRequest mLocationRequest = new LocationRequest();
    mLocationRequest.setInterval(interval);
    mLocationRequest.setFastestInterval(fastInterval);

    if (Geolocation.LEVEL_EXACT.equals(this.level))
        mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
    else if (Geolocation.LEVEL_BUILDING.equals(this.level))
        mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
    else
        mLocationRequest.setPriority(LocationRequest.PRIORITY_LOW_POWER);

    LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, this);
}
项目:PrivacyStreams    文件:GoogleCurrentLocationProvider.java   
@Override
public void onConnected(@Nullable Bundle bundle) {
    long interval = 100L;
    long fastInterval = interval / 2;
    LocationRequest mLocationRequest = new LocationRequest();
    mLocationRequest.setInterval(interval);
    mLocationRequest.setFastestInterval(fastInterval);

    if (Geolocation.LEVEL_EXACT.equals(this.level))
        mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
    else if (Geolocation.LEVEL_BUILDING.equals(this.level))
        mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
    else
        mLocationRequest.setPriority(LocationRequest.PRIORITY_LOW_POWER);
    LocationServices.FusedLocationApi.requestLocationUpdates(this.mGoogleApiClient, mLocationRequest, this);
}
项目:Crimson    文件:SearchClinics.java   
private void getLocation() {

        mGoogleApiClient = new GoogleApiClient.Builder(this)
                .addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this)
                .addApi(LocationServices.API)
                .addApi(Places.GEO_DATA_API)
                .addApi(Places.PLACE_DETECTION_API)
                .enableAutoManage(this, this)
                .build();

        mLocationRequest = LocationRequest.create()
                .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY)
                .setInterval(10 * 1000)
                .setFastestInterval(1 * 1000);

    }
项目:RxJava2-weather-example    文件:MainActivity.java   
@SuppressWarnings("MissingPermission")
private void requestLocationAndWeather() {
    Log.d(TAG, "requesting location");
    RxLocation rxLocation = new RxLocation(getApplicationContext());

    LocationRequest locationRequest = LocationRequest.create()
            .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY)
            .setNumUpdates(1);

    rxLocation.location().updates(locationRequest)
            .flatMap(location -> {
                Log.d(TAG, "requesting weather");
                String key = "abf1b0eed723ba91680f088d90290e6a";
                return mDarkSkyApi.forecast(key, location.getLatitude(), location.getLongitude())
                        .subscribeOn(Schedulers.io());
            })
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(weatherDataJson -> {
                String currentWeather = weatherDataJson.get("currently").getAsJsonObject()
                        .get("summary").getAsString();
                mTextView.setText(currentWeather);
            });
}
项目:Moodr    文件:MapsActivity.java   
@Override
public void onConnected(Bundle bundle) {
    Toast.makeText(this, "onConnected", Toast.LENGTH_SHORT).show();

    mLocationRequest = new LocationRequest();
    mLocationRequest.setInterval(1000);
    mLocationRequest.setFastestInterval(1000);
    mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);

    //mLocationRequest.setSmallestDisplacement(0.1F);

    if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
        // TODO: Consider calling
        //    ActivityCompat#requestPermissions
        // here to request the missing permissions, and then overriding
        //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
        //                                          int[] grantResults)
        // to handle the case where the user grants the permission. See the documentation
        // for ActivityCompat#requestPermissions for more details.
        return;
    }
    LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, this);
}
项目:react-native-fused-location    文件:FusedLocationModule.java   
@ReactMethod
public void setLocationPriority(int mLocationPriority) {
    switch (mLocationPriority) {
        case 0:
            this.mLocationPriority = LocationRequest.PRIORITY_HIGH_ACCURACY;
            break;
        case 1:
            this.mLocationPriority = LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY;
            break;
        case 2:
            this.mLocationPriority = LocationRequest.PRIORITY_LOW_POWER;
            break;
        case 3:
            this.mLocationPriority = LocationRequest.PRIORITY_NO_POWER;
            break;
    }
}
项目:2017.2-codigo    文件:FusedLocationMapActivity.java   
@Override
public void onConnected(Bundle bundle) {

    //inicializa list view
    adapter=new ArrayAdapter<Location>(this, android.R.layout.simple_list_item_1, data);
    setListAdapter(adapter);

    //define requisicao para obter localizacao
    //objeto define quantos updates serao necessarios
    //deadline para desistir se nao conseguir obter location
    //intervalo
    //otimizacao de energia, caso aplicavel
    locationRequest = new LocationRequest()
            .setNumUpdates(5)
            .setExpirationDuration(60000)
            .setInterval(1000)
            .setPriority(LocationRequest.PRIORITY_LOW_POWER);


    LocationSettingsRequest.Builder b = new LocationSettingsRequest.Builder().addLocationRequest(locationRequest);
    PendingResult<LocationSettingsResult> result = LocationServices.SettingsApi.checkLocationSettings(playServices, b.build());
    result.setResultCallback(this);
}
项目:My-Android-Base-Code    文件:LocationRepository.java   
private Single<Location> getLocation(LocationRequest request) {
    if (!shouldRequestNewLocation()) {
        return Single.just(mLastLocation);
    }

    return mFusedLocation.getLocation(request)
            .doOnSuccess(new Consumer<Location>() {
                @Override
                public void accept(Location location) throws Exception {
                    setLocationCache(location);
                }
            })
            .timeout(LOCATION_REQUEST_TIMEOUT, TimeUnit.MILLISECONDS)
            .onErrorResumeNext(new Function<Throwable, SingleSource<? extends Location>>() {
                @Override
                public SingleSource<? extends Location> apply(Throwable e) throws Exception {
                    if (e instanceof TimeoutException && mLastLocation == null) {
                        return Single.error(new LocationTimeoutException());
                    } else if (mLastLocation == null) {
                        return Single.error(e);
                    } else {
                        return Single.just(mLastLocation);
                    }
                }
            });
}
项目:VennTracker    文件:MapsActivity.java   
@Override
public void onConnected(Bundle bundle) {
    LocationRequest locationRequest = new LocationRequest();
    locationRequest.setInterval(1500);
    locationRequest.setFastestInterval(1500);
    locationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
    if (ContextCompat.checkSelfPermission(this,
            Manifest.permission.ACCESS_FINE_LOCATION)
            == PackageManager.PERMISSION_GRANTED) {
        LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, locationRequest, this);
    }
    getLocation();

    // Display # of spawn points loaded.
    // Make sure we have a location first.
    // If we run loadSpawnPoints before Google Play Services finds the location, we get a crash.
    if (mLastLocation != null) {
        loadSpawnPoints();
    }
    else {
        Toast.makeText(MapsActivity.this,
                "Location could not be detected, no spawn points loaded (try reloading from menu)",
                Toast.LENGTH_LONG).show();
    }
    mPolygonPointsGreen = Circles.loadAllPolygons(MapsActivity.this, mMap, mMarkerTransparency);
}
项目:GoMeet    文件:LocationMonitoringService.java   
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    mLocationClient = new GoogleApiClient.Builder(this)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .addApi(LocationServices.API)
            .build();

    mLocationRequest.setInterval(Constants.LOCATION_INTERVAL);
    mLocationRequest.setFastestInterval(Constants.FASTEST_LOCATION_INTERVAL);

    int priority = LocationRequest.PRIORITY_HIGH_ACCURACY;

    mLocationRequest.setPriority(priority);
    mLocationClient.connect();

    return START_STICKY;
}
项目:mapbox-events-android    文件:GoogleLocationEngine.java   
@Override
public void requestLocationUpdates() {
  LocationRequest request = LocationRequest.create();

  if (interval != null) {
    request.setInterval(interval);
  }
  if (fastestInterval != null) {
    request.setFastestInterval(fastestInterval);
  }
  if (smallestDisplacement != null) {
    request.setSmallestDisplacement(smallestDisplacement);
  }

  updateRequestPriority(request);

  if (googleApiClient.isConnected()) {
    //noinspection MissingPermission
    LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, request, this);
  }
}
项目:Leanplum-Android-SDK    文件:LeanplumLocationManagerTest.java   
/**
 * Tests for requestLocation.
 *
 * @throws Exception
 */
@Test
public void requestLocation() throws Exception {
  GoogleApiClient mockGoogleApiClient = mock(GoogleApiClient.class);
  doReturn(true).when(mockGoogleApiClient).isConnected();

  LocationManager mockLocationManager = spy(mLocationManager);
  Whitebox.setInternalState(mockLocationManager, "googleApiClient", mockGoogleApiClient);

  FusedLocationProviderApi mockLocationProviderApi = mock(FusedLocationProviderApi.class);
  Whitebox.setInternalState(LocationServices.class, "FusedLocationApi", mockLocationProviderApi);

  // Testing when a customer did not disableLocationCollection.
  Whitebox.invokeMethod(mockLocationManager, "requestLocation");
  verify(mockLocationProviderApi).requestLocationUpdates(any(GoogleApiClient.class),
      any(LocationRequest.class), any(LocationListener.class));

  // Testing when a customer disableLocationCollection.
  Leanplum.disableLocationCollection();
  Whitebox.invokeMethod(mockLocationManager, "requestLocation");
  verifyNoMoreInteractions(mockLocationProviderApi);
}
项目:iSPY    文件:TrackerService.java   
@Override
public void onConnected(Bundle bundle) {
    LocationRequest request = new LocationRequest();
    request.setInterval(mFirebaseRemoteConfig.getLong("LOCATION_REQUEST_INTERVAL"));
    request.setFastestInterval(mFirebaseRemoteConfig.getLong
            ("LOCATION_REQUEST_INTERVAL_FASTEST"));
    request.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
    LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient,
            request, TrackerService.this);
    setStatusMessage(R.string.tracking);

    // Hold a partial wake lock to keep CPU awake when the we're tracking location.
    PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
    mWakelock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MyWakelockTag");
    mWakelock.acquire();
}
项目:proto-collecte    文件:ParcoursService.java   
private void configureLocationConnection() {
    LocationRequest locationRequest = createLocationRequest();
    LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder().addLocationRequest(locationRequest);
    PendingResult<LocationSettingsResult> locationSettingsResultPendingResult = LocationServices.SettingsApi.checkLocationSettings(mGoogleApiClient, builder.build());
    locationSettingsResultPendingResult
            .setResultCallback(new ResultCallback<LocationSettingsResult>() {
                @Override
                public void onResult(LocationSettingsResult result) {
                    if (LocationSettingsStatusCodes.SUCCESS != result.getStatus().getStatusCode()) {
                        Intent localIntent = new Intent(Constants.GOOGLE_API).putExtra(Constants.GOOGLE_API_LOCATION_RESULT, result.getStatus());
                        LocalBroadcastManager.getInstance(ParcoursService.this).sendBroadcast(localIntent);
                    }
                }
            });
    // noinspection MissingPermission : permissions dans le manifest
    LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, locationRequest, this);
}
项目:TreasureHunting    文件:LocationService.java   
private void setUpComponents() {
    _locationRequest = new LocationRequest();
    _locationRequest.setInterval(10000);
    _locationRequest.setFastestInterval(5000);
    _locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

    _googleApiClient = new GoogleApiClient.Builder(this)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .addApi(LocationServices.API)
            .build();
}
项目:Self-Driving-Car    文件:MapsActivity.java   
@Override
public void onConnected(@Nullable Bundle bundle) {

    mLocationRequest = new LocationRequest();
    mLocationRequest.setInterval(100);
    mLocationRequest.setFastestInterval(100);
    mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
    if (ContextCompat.checkSelfPermission(this,
            android.Manifest.permission.ACCESS_FINE_LOCATION)
            == PackageManager.PERMISSION_GRANTED) {
        LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, this);
    }
}
项目:AndroidAppBoilerplate    文件:LocationTracker.java   
/**
 * Creating location request object
 */
private void createLocationRequest() {
    mLocationRequest = new LocationRequest();
    mLocationRequest.setInterval(UPDATE_INTERVAL);
    mLocationRequest.setFastestInterval(FATEST_INTERVAL);
    mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
    mLocationRequest.setSmallestDisplacement(DISPLACEMENT);
}
项目:AstronomyTourPadova    文件:LocationService.java   
private void createLocationRequest(String precisionLevel) {
    Log.d(TAG, "createLocationRequest()");

    locationRequest = new LocationRequest();
    locationRequest.setInterval(UPDATE_INTERVAL_IN_MILLISECONDS_PRECISION_HIGHEST);
    locationRequest.setFastestInterval(FASTEST_UPDATE_INTERVAL_IN_MILLISECONDS_PRECISION_HIGHEST);
    locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
}
项目:RxTask    文件:RxFusedLocationProviderClient.java   
@RequiresPermission(
        anyOf = {"android.permission.ACCESS_COARSE_LOCATION", "android.permission" +
                ".ACCESS_FINE_LOCATION"}
)
public Completable requestLocationUpdates(LocationRequest request, PendingIntent
        callbackIntent) {
    return CompletableTask.create(() -> client.requestLocationUpdates(request, callbackIntent));
}
项目:react-native-location-switch    文件:LocationSwitch.java   
public void setup(final Callback successCallback, final Callback errorCallback,
                  final int interval, final boolean requestHighAccuracy) {
    mInterval = interval;
    mErrorCallback = errorCallback;
    mSuccessCallback = successCallback;

    if (requestHighAccuracy) {
        mAccuracy = LocationRequest.PRIORITY_HIGH_ACCURACY;
    } else {
        mAccuracy = LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY;
    }
}
项目:MapsWithPlacesAutoComplete    文件:MapsActivity.java   
/**
 * Method to initialize LocationRequest
 */
protected void createLocationRequest() {
    mLocationRequest = new LocationRequest();
    mLocationRequest.setInterval(10000);
    mLocationRequest.setFastestInterval(5000);
    mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY | LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
}
项目:LocGetter    文件:LocationGetterImpl.java   
/**
 * @param logger          for custom logging
 * @param ctx             application context to prevent leaks
 * @param request         location request to define
 * @param googleApiClient needed for turning on locations api
 */
LocationGetterImpl(Logger logger, Context ctx, LocationRequest request, GoogleApiClient googleApiClient) {
    this.logger = logger;
    this.googleApiClient = googleApiClient;
    appContext = ctx;
    locationRequest = request;
}
项目:LocGetter    文件:LocationGetterBuilder.java   
private LocationRequest getLocationRequestByParams(long fastestInterval, long interval, int priority) {
    LocationRequest locationrequest = new LocationRequest();
    locationrequest.setFastestInterval(fastestInterval);
    locationrequest.setInterval(interval);
    locationrequest.setPriority(priority);
    return locationrequest;
}
项目:react-native-geo-fence    文件:RNGeoFenceModule.java   
private void startLocationUpdates() {
    Log.i(TAG, "startLocationUpdates()");
    LocationRequest locationRequest = LocationRequest.create()
            .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY)
            .setInterval(UPDATE_INTERVAL)
            .setFastestInterval(FASTEST_INTERVAL);
    if (checkPermission()) {
        LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, locationRequest, this, Looper.getMainLooper());
    }
}
项目:routineKeen    文件:MapsActivity.java   
@Override
public void onConnected(@Nullable Bundle bundle) {
    locationRequest = new LocationRequest();

    locationRequest.setInterval(1000);
    locationRequest.setFastestInterval(1000);
    locationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);

    if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) ==
            PackageManager.PERMISSION_GRANTED) {
        LocationServices.FusedLocationApi.requestLocationUpdates(client, locationRequest, this);
    }

}
项目:HabitUp    文件:MapsActivity.java   
@Override
public void onConnected(Bundle bundle) {
    mLocationRequest = new LocationRequest();
    mLocationRequest.setInterval(1000);
    mLocationRequest.setFastestInterval(1000);
    mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
    if (ContextCompat.checkSelfPermission(this,
            Manifest.permission.ACCESS_FINE_LOCATION)
            == PackageManager.PERMISSION_GRANTED) {
        LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, this);
    }
}
项目:flutter_geolocation    文件:GpsCoordinatesPlugin.java   
private void connectToGoogleClient() {
  ConnectionManager _connManager = new ConnectionManager();
  _client = new GoogleApiClient.Builder(_activity)
          .addConnectionCallbacks(_connManager)
          .addOnConnectionFailedListener(_connManager)
          .addApi(LocationServices.API)
          .build();
  _locationRequest = new LocationRequest()
          .setInterval(5)
          .setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
  _client.connect();
}
项目:openlocate-android    文件:LocationServiceHelper.java   
private LocationRequest getLocationRequest() {
    LocationRequest request = new LocationRequest();

    request.setPriority(accuracy.getLocationRequestAccuracy());
    request.setInterval(locationRequestIntervalInSecs * 1000);
    request.setFastestInterval(Constants.DEFAULT_FAST_LOCATION_INTERVAL_SEC * 1000);

    return request;
}
项目:RxGps    文件:RxGps.java   
public Observable<Location> locationLowPower() {
    return location(LocationRequest.create()
                    .setPriority(LocationRequest.PRIORITY_LOW_POWER)
                    .setInterval(interval),
            Manifest.permission.ACCESS_COARSE_LOCATION
    );
}
项目:speedr    文件:MainActivity.java   
private void enableGPSViaPlayServices() {
    Crashlytics.log(Log.INFO, MainActivity.class.getSimpleName(), "enableGPSViaPlayServices()");

    googleApiClient = new GoogleApiClient.Builder(this)
            .addApi(LocationServices.API)
            .build();
    googleApiClient.connect();

    LocationSettingsRequest locationSettingsRequest = new LocationSettingsRequest.Builder()
            .addLocationRequest(new LocationRequest().setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY))
            .setAlwaysShow(true)
            .build();

    LocationServices.SettingsApi.checkLocationSettings(googleApiClient, locationSettingsRequest)
    .setResultCallback(new ResultCallback<LocationSettingsResult>() {
        @Override
        public void onResult(@NonNull LocationSettingsResult result) {
            boolean showingLocationSettingsDialog = false;
            if (result.getStatus().getStatusCode() == LocationSettingsStatusCodes.RESOLUTION_REQUIRED) {
                try {
                    //Show location settings change dialog and check the result in onActivityResult()
                    result.getStatus().startResolutionForResult(MainActivity.this, REQUEST_LOCATION);
                    showingLocationSettingsDialog = true;
                    Crashlytics.log(Log.INFO, MainActivity.class.getSimpleName(), "Showing PlayServices GPS settings dialog");
                } catch (Exception e) {
                    Crashlytics.log(Log.ERROR, MainActivity.class.getSimpleName(), "Error showing PlayServices GPS settings dialog");
                    Crashlytics.logException(e);
                }
            }
            if (!showingLocationSettingsDialog) {
                showNoGPSAlert(); //Ask user to manually enable GPS
                googleApiClient.disconnect();
            }
        }
    });
}
项目:LocationAware    文件:LocationProvider.java   
@NonNull private LocationRequest getLocationRequest() {
  LocationRequest locationRequest = new LocationRequest();
  locationRequest.setInterval(LOCATION_UPDATE_INTERVAL);
  locationRequest.setFastestInterval(LOCATION_UPDATE_FASTEST_INTERVAL);
  locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
  return locationRequest;
}
项目:foodie    文件:HomeActivity.java   
@Override
public void onConnected(@Nullable Bundle bundle) {
    LocationRequest locationRequest = new LocationRequest();
    locationRequest.setInterval(REQUEST_INTERVAL);
    locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
    if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
        // Request location updates from the Google API client
        LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, locationRequest, this);
    }
}