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


Java LocationRequest.setPriority方法代碼示例

本文整理匯總了Java中com.google.android.gms.location.LocationRequest.setPriority方法的典型用法代碼示例。如果您正苦於以下問題:Java LocationRequest.setPriority方法的具體用法?Java LocationRequest.setPriority怎麽用?Java LocationRequest.setPriority使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.android.gms.location.LocationRequest的用法示例。


在下文中一共展示了LocationRequest.setPriority方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: requestLocationUpdates

import com.google.android.gms.location.LocationRequest; //導入方法依賴的package包/類
@Override
public void requestLocationUpdates() {
  // Common params
  LocationRequest request = LocationRequest.create()
    .setInterval(0)
    .setSmallestDisplacement(3.0f)
    .setMaxWaitTime(1500);

  // Priority matching is straightforward
  if (priority == LocationEnginePriority.NO_POWER) {
    request.setPriority(LocationRequest.PRIORITY_NO_POWER);
  } else if (priority == LocationEnginePriority.LOW_POWER) {
    request.setPriority(LocationRequest.PRIORITY_LOW_POWER);
  } else if (priority == LocationEnginePriority.BALANCED_POWER_ACCURACY) {
    request.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
  } else if (priority == LocationEnginePriority.HIGH_ACCURACY) {
    request.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
  }

  if (googleApiClient.isConnected() && PermissionsManager.areLocationPermissionsGranted(context.get())) {
    //noinspection MissingPermission
    LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, request, this);
  }
}
 
開發者ID:mapbox,項目名稱:mapbox-navigation-hud-demo,代碼行數:25,代碼來源:GoogleLocationEngine.java

示例2: onConnected

import com.google.android.gms.location.LocationRequest; //導入方法依賴的package包/類
@Override
public void onConnected(@Nullable Bundle bundle) {
    long interval = 100L;
    long fastInterval = interval / 2;
    LocationRequest mLocationRequest = new LocationRequest();
    mLocationRequest.setInterval(interval);
    mLocationRequest.setFastestInterval(fastInterval);

    if (Geolocation.LEVEL_EXACT.equals(this.level))
        mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
    else if (Geolocation.LEVEL_BUILDING.equals(this.level))
        mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
    else
        mLocationRequest.setPriority(LocationRequest.PRIORITY_LOW_POWER);
    LocationServices.FusedLocationApi.requestLocationUpdates(this.mGoogleApiClient, mLocationRequest, this);
}
 
開發者ID:PrivacyStreams,項目名稱:PrivacyStreams,代碼行數:17,代碼來源:GoogleCurrentLocationProvider.java

示例3: createLocationRequest

import com.google.android.gms.location.LocationRequest; //導入方法依賴的package包/類
/**
 * Sets up the location request.
 */
private 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);
}
 
開發者ID:Francescopaolo44,項目名稱:MedicalMe,代碼行數:23,代碼來源:MapsActivity.java

示例4: onCreate

import com.google.android.gms.location.LocationRequest; //導入方法依賴的package包/類
@Override
public void onCreate() {
    super.onCreate();

    mContext = this;

    mLocationRequest = new LocationRequest();
    mLocationRequest.setInterval(INTERVAL);
    mLocationRequest.setFastestInterval(FASTEST_INTERVAL);
    mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .addApi(LocationServices.API)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .build();
}
 
開發者ID:dilipkumar4813,項目名稱:LocationTracking,代碼行數:18,代碼來源:BackgroundTrackingService.java

示例5: findImage

import com.google.android.gms.location.LocationRequest; //導入方法依賴的package包/類
private void findImage() {
    LocationRequest request = LocationRequest.create();
    request.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
    request.setNumUpdates(1);
    request.setInterval(0);
    LocationServices.FusedLocationApi
            .requestLocationUpdates(mClient, request, new LocationListener() {
                @Override
                public void onLocationChanged(Location location) {
                    Log.i(TAG, "Got a fix: " + location);
                    new SearchTask().execute(location);
                }
            });
}
 
開發者ID:rsippl,項目名稱:AndroidProgramming3e,代碼行數:15,代碼來源:LocatrFragment.java

示例6: onConnected

import com.google.android.gms.location.LocationRequest; //導入方法依賴的package包/類
@Override
public void onConnected(@Nullable Bundle bundle) {

    mLocationRequest = new LocationRequest();
    mLocationRequest.setInterval(100);
    mLocationRequest.setFastestInterval(100);
    mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
    if (ContextCompat.checkSelfPermission(this,
            android.Manifest.permission.ACCESS_FINE_LOCATION)
            == PackageManager.PERMISSION_GRANTED) {
        LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, this);
    }
}
 
開發者ID:GeekyShiva,項目名稱:Self-Driving-Car,代碼行數:14,代碼來源:MapsActivity.java

示例7: onConnected

import com.google.android.gms.location.LocationRequest; //導入方法依賴的package包/類
@Override
public void onConnected(@Nullable Bundle bundle) {
    LocationRequest locationRequest = new LocationRequest();
    locationRequest.setInterval(REQUEST_INTERVAL);
    locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
    if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
        // Request location updates from the Google API client
        LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, locationRequest, this);
    }
}
 
開發者ID:thandomy,項目名稱:foodie,代碼行數:11,代碼來源:HomeActivity.java

示例8: createLocationRequest

import com.google.android.gms.location.LocationRequest; //導入方法依賴的package包/類
protected LocationRequest createLocationRequest() {
    LocationRequest mLocationRequest = new LocationRequest();
    mLocationRequest.setInterval(1000);
    mLocationRequest.setFastestInterval(500);
    mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
    return mLocationRequest;
}
 
開發者ID:KrishAmal,項目名稱:NavAR,代碼行數:8,代碼來源:ArCamActivity.java

示例9: onCreate

import com.google.android.gms.location.LocationRequest; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Retrieve location and camera position from saved instance state.
    if (savedInstanceState != null) {
        mLastKnownLocation = savedInstanceState.getParcelable(KEY_LOCATION);
    }
    locationInfoList = new ArrayList<LocationInfo>();
    setContentView(R.layout.activity_main);
    //helper = new MyDBHelper(this, "expense.db", null, 1);

    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .enableAutoManage(this /* FragmentActivity */,
                    this /* OnConnectionFailedListener */)
            .addApi(LocationServices.API)
            .addApi(Places.GEO_DATA_API)
            .addApi(Places.PLACE_DETECTION_API)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .build();
    mGoogleApiClient.connect();
    mLocationRequest = new LocationRequest();
    mLocationRequest.setInterval(10*1000);
    mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
    mLocationRequest.setFastestInterval(1000);


}
 
開發者ID:jorseph,項目名稱:SearchRestaurant,代碼行數:29,代碼來源:MainActivity.java

示例10: onConnected

import com.google.android.gms.location.LocationRequest; //導入方法依賴的package包/類
@Override
public void onConnected(Bundle bundle) {
    mLocationRequest = new LocationRequest();
    mLocationRequest.setInterval(1000);
    mLocationRequest.setFastestInterval(1000);
    mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
    if (ContextCompat.checkSelfPermission(this,
            Manifest.permission.ACCESS_FINE_LOCATION)
            == PackageManager.PERMISSION_GRANTED) {
        LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, this);
    }
}
 
開發者ID:kayaaliemre,項目名稱:GoogleMapsApp,代碼行數:13,代碼來源:MapsActivity.java

示例11: createLocationRequest

import com.google.android.gms.location.LocationRequest; //導入方法依賴的package包/類
private LocationRequest createLocationRequest() {
    LocationRequest locationRequest = new LocationRequest();
    locationRequest.setInterval(collecteFrequencePref);
    locationRequest.setFastestInterval(collecteFrequencePref / 2);
    locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
    return locationRequest;
}
 
開發者ID:ANFR-France,項目名稱:proto-collecte,代碼行數:8,代碼來源:CollecteService.java

示例12: 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

示例13: createLocationRequest

import com.google.android.gms.location.LocationRequest; //導入方法依賴的package包/類
/**
 * Initialize the LocationRequest field of the fragment and setup all
 * necessary parameters using the apposite constants.
 */
private LocationRequest createLocationRequest() {
    LocationRequest locationRequest = new LocationRequest();

    locationRequest.setInterval(UPDATE_INTERVAL_IN_MILLISECONDS);
    locationRequest.setFastestInterval(FASTEST_UPDATE_INTERVAL_IN_MILLISECONDS);
    locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

    return locationRequest;
}
 
開發者ID:IrrilevantHappyLlamas,項目名稱:Runnest,代碼行數:14,代碼來源:LocationSettingsHandler.java

示例14: findCoords

import com.google.android.gms.location.LocationRequest; //導入方法依賴的package包/類
private void findCoords() {
    LocationRequest request = LocationRequest.create();
    request.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
    request.setNumUpdates(1);
    request.setInterval(0);

    LocationServices.FusedLocationApi
            .requestLocationUpdates(mClient, request, new LocationListener() {
                @Override
                public void onLocationChanged(Location location) {
                    double lat = location.getLatitude();
                    double lon = location.getLongitude();
                    mLocation.setLatitude(lat);
                    mLocation.setLongitude(lon);
                    mWasLocationFixed = true;
                    
                    //Sort the order in which places are shown
                    //depending on how far they are from us (= by distance ascending)
                    Collections.sort(mPlaces, new Comparator<Visitable>() {
                        @Override
                        public int compare(Visitable a, Visitable b) {
                            Location aLoc = a.getLocation();
                            Location bLoc = b.getLocation();
                            return (int) aLoc.distanceTo(mLocation) - (int) bLoc.distanceTo(mLocation);
                        }
                    });
                    mAdapter.setPlaces(mPlaces);
                    mAdapter.notifyDataSetChanged();
                }
            });
}
 
開發者ID:plweegie,項目名稱:piast-trail,代碼行數:32,代碼來源:PlaceListFragment.java

示例15: createLocationRequest

import com.google.android.gms.location.LocationRequest; //導入方法依賴的package包/類
/**
 * Method to initialize LocationRequest
 */
protected void createLocationRequest() {
    mLocationRequest = new LocationRequest();
    mLocationRequest.setInterval(10000);
    mLocationRequest.setFastestInterval(5000);
    mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY | LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
}
 
開發者ID:pmathew92,項目名稱:MapsWithPlacesAutoComplete,代碼行數:10,代碼來源:MapsActivity.java


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