本文整理匯總了Java中com.google.android.gms.location.LocationRequest.setFastestInterval方法的典型用法代碼示例。如果您正苦於以下問題:Java LocationRequest.setFastestInterval方法的具體用法?Java LocationRequest.setFastestInterval怎麽用?Java LocationRequest.setFastestInterval使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.android.gms.location.LocationRequest
的用法示例。
在下文中一共展示了LocationRequest.setFastestInterval方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onConnected
import com.google.android.gms.location.LocationRequest; //導入方法依賴的package包/類
@Override
public void onConnected(@Nullable Bundle bundle) {
Log.d(TAG, "Google API client connected");
// String locationProvider = LocationManager.GPS_PROVIDER;
mLocationRequest = new LocationRequest();
mLocationRequest.setInterval(5000);
mLocationRequest.setFastestInterval(500);
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
// We should have permission as we ask for it at startup.
} else {
LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, this);
}
}
示例2: 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);
}
}
示例3: 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);
}
示例4: onConnected
import com.google.android.gms.location.LocationRequest; //導入方法依賴的package包/類
@Override
public void onConnected(Bundle bundle) {
Toast.makeText(this, "onConnected", Toast.LENGTH_SHORT).show();
mLocationRequest = new LocationRequest();
mLocationRequest.setInterval(1000);
mLocationRequest.setFastestInterval(1000);
mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
//mLocationRequest.setSmallestDisplacement(0.1F);
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) {
// TODO: Consider calling
// ActivityCompat#requestPermissions
// here to request the missing permissions, and then overriding
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
// int[] grantResults)
// to handle the case where the user grants the permission. See the documentation
// for ActivityCompat#requestPermissions for more details.
return;
}
LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, this);
}
示例5: onConnected
import com.google.android.gms.location.LocationRequest; //導入方法依賴的package包/類
@Override
public void onConnected(Bundle bundle) {
LocationRequest locationRequest = new LocationRequest();
locationRequest.setInterval(1500);
locationRequest.setFastestInterval(1500);
locationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
if (ContextCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_FINE_LOCATION)
== PackageManager.PERMISSION_GRANTED) {
LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, locationRequest, this);
}
getLocation();
// Display # of spawn points loaded.
// Make sure we have a location first.
// If we run loadSpawnPoints before Google Play Services finds the location, we get a crash.
if (mLastLocation != null) {
loadSpawnPoints();
}
else {
Toast.makeText(MapsActivity.this,
"Location could not be detected, no spawn points loaded (try reloading from menu)",
Toast.LENGTH_LONG).show();
}
mPolygonPointsGreen = Circles.loadAllPolygons(MapsActivity.this, mMap, mMarkerTransparency);
}
示例6: createLocationRequest
import com.google.android.gms.location.LocationRequest; //導入方法依賴的package包/類
/**
* Sets up the location request. Android has two location request settings:
* {@code ACCESS_COARSE_LOCATION} and {@code ACCESS_FINE_LOCATION}. These settings control
* the accuracy of the current location. This sample uses ACCESS_FINE_LOCATION, as defined in
* the AndroidManifest.xml.
* <p/>
* When the ACCESS_FINE_LOCATION setting is specified, combined with a fast update
* interval (5 seconds), the Fused Location Provider API returns location updates that are
* accurate to within a few feet.
* <p/>
* These settings are appropriate for mapping applications that show real-time location
* updates.
*/
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);
}
示例7: startLocationUpdates
import com.google.android.gms.location.LocationRequest; //導入方法依賴的package包/類
protected void startLocationUpdates() {
LocationRequest mLocationRequest = new LocationRequest();
mLocationRequest.setInterval(10000);
mLocationRequest.setFastestInterval(5000);
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
LocationServices.FusedLocationApi.requestLocationUpdates(
mGoogleApiClient, mLocationRequest, this);
}
示例8: onConnected
import com.google.android.gms.location.LocationRequest; //導入方法依賴的package包/類
@Override
public void onConnected(@Nullable Bundle bundle) {
LocationRequest mLocationRequest = new LocationRequest();
mLocationRequest.setInterval(1000);
mLocationRequest.setFastestInterval(1000);
mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
if (ContextCompat.checkSelfPermission(this,
android.Manifest.permission.ACCESS_FINE_LOCATION)
== PackageManager.PERMISSION_GRANTED) {
LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, this);
}
}
示例9: processQueue
import com.google.android.gms.location.LocationRequest; //導入方法依賴的package包/類
private void processQueue() {
if(ContextCompat.checkSelfPermission(queue.getFirst().getContext(), Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED && locationClient != null) {
LocationRequest googleRequest = new LocationRequest();
googleRequest.setInterval(2500);
googleRequest.setFastestInterval(2500);
googleRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
locationClient.requestLocationUpdates(googleRequest, updateCallback, null);
} else {
for(LocationUtilRequest request : queue) {
request.onLocationReceived(null, false);
queue.remove(request);
}
}
}
示例10: getLocationRequest
import com.google.android.gms.location.LocationRequest; //導入方法依賴的package包/類
@NonNull private LocationRequest getLocationRequest() {
LocationRequest locationRequest = new LocationRequest();
locationRequest.setInterval(LOCATION_UPDATE_INTERVAL);
locationRequest.setFastestInterval(LOCATION_UPDATE_FASTEST_INTERVAL);
locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
return locationRequest;
}
示例11: onConnected
import com.google.android.gms.location.LocationRequest; //導入方法依賴的package包/類
@Override
public void onConnected(@Nullable Bundle bundle) {
locationRequest = new LocationRequest();
locationRequest.setInterval(1000);
locationRequest.setFastestInterval(1000);
locationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) ==
PackageManager.PERMISSION_GRANTED) {
LocationServices.FusedLocationApi.requestLocationUpdates(client, locationRequest, this);
}
}
示例12: 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);
}
}
示例13: getLocationRequest
import com.google.android.gms.location.LocationRequest; //導入方法依賴的package包/類
/**
* Sets up the location request.
*
* @return The LocationRequest object containing the desired parameters.
*/
private LocationRequest getLocationRequest() {
LocationRequest locationRequest = new LocationRequest();
locationRequest.setInterval(10000);
locationRequest.setFastestInterval(5000);
locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
return locationRequest;
}
示例14: 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;
}
示例15: 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);
}
}