2

I've a simple app with LocationFused API implementation:

protected void startLocationUpdates() {
    mFusedLocationClient = LocationServices.getFusedLocationProviderClient(this);

    Intent intent = new Intent(this, LocationReceiver.class);
    PendingIntent pi = PendingIntent.getBroadcast(this, 100, intent, PendingIntent.FLAG_UPDATE_CURRENT);

    mFusedLocationClient.requestLocationUpdates(createLocationRequest(), pi);
}

protected LocationRequest createLocationRequest() {
    LocationRequest mLocationRequest = new LocationRequest();
    mLocationRequest.setInterval(5000);
    mLocationRequest.setMaxWaitTime(60000);
    mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
    return mLocationRequest;
}

When the app is deployed on a device, I should expect to receive a batch of locations every 60 seconds as specified in setMaxWaitTime method but this happens only the first time after deploy (I received 7 locations after 1 minute), then I start receiving 1 location every 5 seconds.

Why setMaxWaitTime works only once?

Giulio Bider
  • 1,386
  • 2
  • 10
  • 20

0 Answers0