com.google.android.gms.location.LocationRequest

Here are the examples of the java api class com.google.android.gms.location.LocationRequest taken from open source projects.

1. MainActivity#createLocationRequest()

View license
/**
     * Sets up the location request. Android has two location request settings:
     * {@code ACCESS_COARSE_LOCATION} and {@code ACCESS_FINE_LOCATION}. These settings control
     * the accuracy of the current location. This sample uses ACCESS_FINE_LOCATION, as defined in
     * the AndroidManifest.xml.
     * <p/>
     * When the ACCESS_FINE_LOCATION setting is specified, combined with a fast update
     * interval (5 seconds), the Fused Location Provider API returns location updates that are
     * accurate to within a few feet.
     * <p/>
     * These settings are appropriate for mapping applications that show real-time location
     * updates.
     */
protected void createLocationRequest() {
    mLocationRequest = new LocationRequest();
    // Sets the desired interval for active location updates. This interval is
    // inexact. You may not receive updates at all if no location sources are available, or
    // you may receive them slower than requested. You may also receive updates faster than
    // requested if other applications are requesting location at a faster interval.
    mLocationRequest.setInterval(UPDATE_INTERVAL_IN_MILLISECONDS);
    // Sets the fastest rate for active location updates. This interval is exact, and your
    // application will never receive updates faster than this value.
    mLocationRequest.setFastestInterval(FASTEST_UPDATE_INTERVAL_IN_MILLISECONDS);
    mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
}

2. MainActivity#createLocationRequest()

View license
/**
     * Sets up the location request. Android has two location request settings:
     * {@code ACCESS_COARSE_LOCATION} and {@code ACCESS_FINE_LOCATION}. These settings control
     * the accuracy of the current location. This sample uses ACCESS_FINE_LOCATION, as defined in
     * the AndroidManifest.xml.
     * <p/>
     * When the ACCESS_FINE_LOCATION setting is specified, combined with a fast update
     * interval (5 seconds), the Fused Location Provider API returns location updates that are
     * accurate to within a few feet.
     * <p/>
     * These settings are appropriate for mapping applications that show real-time location
     * updates.
     */
protected void createLocationRequest() {
    mLocationRequest = new LocationRequest();
    // Sets the desired interval for active location updates. This interval is
    // inexact. You may not receive updates at all if no location sources are available, or
    // you may receive them slower than requested. You may also receive updates faster than
    // requested if other applications are requesting location at a faster interval.
    mLocationRequest.setInterval(UPDATE_INTERVAL_IN_MILLISECONDS);
    // Sets the fastest rate for active location updates. This interval is exact, and your
    // application will never receive updates faster than this value.
    mLocationRequest.setFastestInterval(FASTEST_UPDATE_INTERVAL_IN_MILLISECONDS);
    mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
}

3. LocationSender#getFreshLocation()

Project: Atlas-Android
Source File: LocationSender.java
View license
@RequiresPermission(PERMISSION)
private static boolean getFreshLocation(LocationListener listener) {
    if (sGoogleApiClient == null) {
        if (Log.isLoggable(Log.ERROR))
            Log.e("GoogleApiClient not initialized");
        return false;
    }
    if (Log.isLoggable(Log.VERBOSE))
        Log.v("Getting fresh location");
    LocationRequest r = new LocationRequest().setNumUpdates(1).setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY).setExpirationDuration(10000).setMaxWaitTime(10000);
    try {
        LocationServices.FusedLocationApi.requestLocationUpdates(sGoogleApiClient, r, listener);
        return true;
    } catch (IllegalStateException e) {
        if (Log.isLoggable(Log.ERROR)) {
            Log.e(e.getMessage(), e);
        }
    }
    return false;
}

4. BaseFlightControlFragment#enableFollowMe()

View license
private void enableFollowMe(final Drone drone) {
    if (drone == null)
        return;
    final LocationRequest locationReq = LocationRequest.create().setPriority(FOLLOW_LOCATION_PRIORITY).setFastestInterval(FOLLOW_LOCATION_UPDATE_FASTEST_INTERVAL).setInterval(FOLLOW_LOCATION_UPDATE_INTERVAL).setSmallestDisplacement(FOLLOW_LOCATION_UPDATE_MIN_DISPLACEMENT);
    final CheckLocationSettings locationSettingsChecker = new CheckLocationSettings(getActivity(), locationReq, new Runnable() {

        @Override
        public void run() {
            FollowApi.getApi(drone).enableFollowMe(FollowType.LEASH);
        }
    });
    locationSettingsChecker.check();
}