PRIORITY_HIGH_ACCURACY是更有可能使用GPS,並PRIORITY_BALANCED_POWER_ACCURACY是更有可能使用WIFI &蜂窩塔的定位。
例子:
private static final long INTERVAL = 60 * 1000;
private static final long FASTEST_INTERVAL = 5 * 1000;
private static final long DISPLACEMENT = 100;
private LocationRequest createLocationRequest(){
LocationRequest mLocationRequest = new LocationRequest();
mLocationRequest.setInterval(INTERVAL);
mLocationRequest.setFastestInterval(FASTEST_INTERVAL);
mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
mLocationRequest.setSmallestDisplacement(DISPLACEMENT);
return mLocationRequest;
}
谷歌在這裏介紹了LocationRequest
類:http://developer.android.com/reference/com/google/android/gms/location/LocationRequest.html