當前位置: 首頁>>代碼示例>>Java>>正文


Java LocationRequest.setSmallestDisplacement方法代碼示例

本文整理匯總了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);
  }
}
 
開發者ID:mapbox,項目名稱:mapbox-events-android,代碼行數:22,代碼來源:GoogleLocationEngine.java

示例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);
}
 
開發者ID:SoftprodigyIndia,項目名稱:AndroidAppBoilerplate,代碼行數:11,代碼來源:LocationTracker.java

示例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);
}
 
開發者ID:Nishant-Pathak,項目名稱:mocket_android_demo,代碼行數:28,代碼來源:MapsActivity.java

示例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;
}
 
開發者ID:MustansirZia,項目名稱:react-native-fused-location,代碼行數:9,代碼來源:FusedLocationModule.java


注:本文中的com.google.android.gms.location.LocationRequest.setSmallestDisplacement方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。