Why requestLocationUpdates fire immediatly onReceive?

82 Views Asked by At

When i execute requestLocationUpdates like this :

FusedLocationProviderClient fusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(context);    

LocationRequest locationRequest = new LocationRequest();
locationRequest.setInterval(150000);
locationRequest.setFastestInterval(30000);
locationRequest.setMaxWaitTime(900000);
locationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
locationRequest.setSmallestDisplacement(0);

fusedLocationProviderClient.requestLocationUpdates(locationRequest, getPendingIntent(context));

then the onReceive(Context context, Intent intent) is immediatly fired without taking care of the setMaxWaitTime(900000). Is it a normal/documented behavior ?

1

There are 1 best solutions below

1
On

In LocationUpdatesPendingIntent there is a small disclaimer:

    // Sets the maximum time when batched location updates are delivered. Updates may be
    // delivered sooner than this interval.
    mLocationRequest.setMaxWaitTime(MAX_WAIT_TIME);