本文整理汇总了Java中com.google.android.gms.location.LocationRequest.setSmallestDisplacement方法的典型用法代码示例。如果您正苦于以下问题:Java LocationRequest.setSmallestDisplacement方法的具体用法?Java LocationRequest.setSmallestDisplacement怎么用?Java LocationRequest.setSmallestDisplacement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.gms.location.LocationRequest
的用法示例。
在下文中一共展示了LocationRequest.setSmallestDisplacement方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: requestLocationUpdates
import com.google.android.gms.location.LocationRequest; //导入方法依赖的package包/类
@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);
}
}
示例2: createLocationRequest
import com.google.android.gms.location.LocationRequest; //导入方法依赖的package包/类
/**
* 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);
}
示例3: onConnected
import com.google.android.gms.location.LocationRequest; //导入方法依赖的package包/类
@Override
public void onConnected(Bundle bundle) {
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) {
requestPermission();
return;
}
Location mLastLocation = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient);
if (mLastLocation != null) {
latLng = new LatLng(mLastLocation.getLatitude(), mLastLocation.getLongitude());
mMocketClient.pushLatLngToServer(latLng);
MarkerOptions markerOptions = new MarkerOptions();
markerOptions.position(latLng);
markerOptions.title("Current Position");
markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_MAGENTA));
currLocationMarker = mGoogleMap.addMarker(markerOptions);
}
LocationRequest mLocationRequest = new LocationRequest();
mLocationRequest.setInterval(5000); //5 seconds
mLocationRequest.setFastestInterval(3000); //3 seconds
mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
mLocationRequest.setSmallestDisplacement(0.1F); //1/10 meter
LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, this);
}
示例4: buildLR
import com.google.android.gms.location.LocationRequest; //导入方法依赖的package包/类
private LocationRequest buildLR() {
LocationRequest request = new LocationRequest();
request.setPriority(mLocationPriority);
request.setInterval(mLocationInterval);
request.setFastestInterval(mLocationFastestInterval);
request.setSmallestDisplacement(mSmallestDisplacement);
return request;
}