Java Code Examples for com.google.android.gms.location.LocationRequest#PRIORITY_BALANCED_POWER_ACCURACY

The following examples show how to use com.google.android.gms.location.LocationRequest#PRIORITY_BALANCED_POWER_ACCURACY . 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: ActivityRecognitionLocationProvider.java    From background-geolocation-android with Apache License 2.0 6 votes vote down vote up
/**
 * Translates a number representing desired accuracy of Geolocation system from set [0, 10, 100, 1000].
 * 0:  most aggressive, most accurate, worst battery drain
 * 1000:  least aggressive, least accurate, best for battery.
 */
private Integer translateDesiredAccuracy(Integer accuracy) {
    if (accuracy >= 10000) {
        return LocationRequest.PRIORITY_NO_POWER;
    }
    if (accuracy >= 1000) {
        return LocationRequest.PRIORITY_LOW_POWER;
    }
    if (accuracy >= 100) {
        return LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY;
    }
    if (accuracy >= 10) {
        return LocationRequest.PRIORITY_HIGH_ACCURACY;
    }
    if (accuracy >= 0) {
        return LocationRequest.PRIORITY_HIGH_ACCURACY;
    }

    return LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY;
}
 
Example 2
Source File: FusedLocationModule.java    From react-native-fused-location with MIT License 6 votes vote down vote up
@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;
    }
}
 
Example 3
Source File: BackgroundLocationUpdateService.java    From cordova-background-geolocation-services with Apache License 2.0 6 votes vote down vote up
/**
 * Translates a number representing desired accuracy of GeoLocation system from set [0, 10, 100, 1000].
 * 0:  most aggressive, most accurate, worst battery drain
 * 1000:  least aggressive, least accurate, best for battery.
 */
private Integer translateDesiredAccuracy(Integer accuracy) {
    if(accuracy <= 0) {
        accuracy = LocationRequest.PRIORITY_HIGH_ACCURACY;
    } else if(accuracy <= 100) {
        accuracy = LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY;
    } else if(accuracy  <= 1000) {
        accuracy = LocationRequest.PRIORITY_LOW_POWER;
    } else if(accuracy <= 10000) {
        accuracy = LocationRequest.PRIORITY_NO_POWER;
    } else {
      accuracy = LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY;
    }

    return accuracy;
}
 
Example 4
Source File: AndroidLocationPlayServiceManager.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
private void setupBackgroundLocationRequest(LocationRequest req) {
    Display d = Display.getInstance();
    String priorityStr = d.getProperty("android.backgroundLocation.priority", "PRIORITY_BALANCED_POWER_ACCURACY");
    String fastestIntervalStr = d.getProperty("android.backgroundLocation.fastestInterval", "5000");
    String intervalStr = d.getProperty("android.backgroundLocation.interval", "10000");
    String smallestDisplacementStr = d.getProperty("android.backgroundLocation.smallestDisplacement", "50");

    int priority = LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY;
    if ("PRIORITY_HIGH_ACCURACY".equals(priorityStr)) {
        priority = LocationRequest.PRIORITY_HIGH_ACCURACY;
    } else if ("PRIORITY_LOW_POWER".equals(priorityStr)) {
        priority = LocationRequest.PRIORITY_LOW_POWER;
    } else if ("PRIORITY_NO_POWER".equals(priorityStr)) {
        priority = LocationRequest.PRIORITY_NO_POWER;
    }

    long interval = Long.parseLong(intervalStr);
    long fastestInterval = Long.parseLong(fastestIntervalStr);
    int smallestDisplacement = Integer.parseInt(smallestDisplacementStr);

    req.setPriority(priority)
            .setFastestInterval(fastestInterval)
            .setInterval(interval)
            .setSmallestDisplacement(smallestDisplacement);
}
 
Example 5
Source File: NativeLocationClientImpl.java    From android_external_GmsLib with Apache License 2.0 6 votes vote down vote up
private static Criteria makeNativeCriteria(LocationRequest request) {
    Criteria criteria = new Criteria();
    switch (request.getPriority()) {
        case LocationRequest.PRIORITY_HIGH_ACCURACY:
            criteria.setAccuracy(Criteria.ACCURACY_FINE);
            criteria.setPowerRequirement(Criteria.POWER_HIGH);
            break;
        case LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY:
        default:
            criteria.setAccuracy(Criteria.ACCURACY_COARSE);
            criteria.setPowerRequirement(Criteria.POWER_MEDIUM);
            break;
        case LocationRequest.PRIORITY_NO_POWER:
        case LocationRequest.PRIORITY_LOW_POWER:
            criteria.setAccuracy(Criteria.ACCURACY_COARSE);
            criteria.setPowerRequirement(Criteria.POWER_LOW);
    }
    return criteria;
}
 
Example 6
Source File: GoogleLocationEngineImpl.java    From mapbox-events-android with MIT License 5 votes vote down vote up
private static int toGMSLocationPriority(int enginePriority) {
  switch (enginePriority) {
    case LocationEngineRequest.PRIORITY_HIGH_ACCURACY:
      return LocationRequest.PRIORITY_HIGH_ACCURACY;
    case LocationEngineRequest.PRIORITY_BALANCED_POWER_ACCURACY:
      return LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY;
    case LocationEngineRequest.PRIORITY_LOW_POWER:
      return LocationRequest.PRIORITY_LOW_POWER;
    case LocationEngineRequest.PRIORITY_NO_POWER:
    default:
      return LocationRequest.PRIORITY_NO_POWER;
  }
}
 
Example 7
Source File: LocationSwitch.java    From react-native-location-switch with Apache License 2.0 5 votes vote down vote up
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;
    }
}