Java Code Examples for com.google.android.gms.location.LocationRequest#setNumUpdates()
The following examples show how to use
com.google.android.gms.location.LocationRequest#setNumUpdates() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LocatrFragment.java From AndroidProgramming3e with Apache License 2.0 | 5 votes |
private void findImage() { LocationRequest request = LocationRequest.create(); request.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); request.setNumUpdates(1); request.setInterval(0); LocationServices.FusedLocationApi .requestLocationUpdates(mClient, request, new LocationListener() { @Override public void onLocationChanged(Location location) { Log.i(TAG, "Got a fix: " + location); new SearchTask().execute(location); } }); }
Example 2
Source File: LocatrFragment.java From AndroidProgramming3e with Apache License 2.0 | 5 votes |
private void findImage() { LocationRequest request = LocationRequest.create(); request.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); request.setNumUpdates(1); request.setInterval(0); LocationServices.FusedLocationApi .requestLocationUpdates(mClient, request, new LocationListener() { @Override public void onLocationChanged(Location location) { Log.i(TAG, "Got a fix: " + location); new SearchTask().execute(location); } }); }
Example 3
Source File: GMSLocationService.java From GeometricWeather with GNU Lesser General Public License v3.0 | 5 votes |
@SuppressLint("MissingPermission") @Override public void requestLocation(Context context, @NonNull LocationCallback callback) { if (!hasPermissions(context)) { callback.onCompleted(null); return; } locationListener = new GMSLocationListener(); locationCallback = callback; lastKnownLocation = null; client.getLastLocation().addOnSuccessListener(location -> lastKnownLocation = location); LocationRequest request = LocationRequest.create(); request.setNumUpdates(1); request.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY); client.requestLocationUpdates(request, locationListener, Looper.getMainLooper()); timer.postDelayed(() -> { if (locationListener != null) { client.removeLocationUpdates(locationListener); locationListener = null; } handleLocation(lastKnownLocation); }, TIMEOUT_MILLIS); }