Почему requestLocationUpdates срабатывает немедленно при получении?
Когда я выполняю requestLocationUpdates следующим образом:
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));
тогда onReceive(Context context, Intent intent)
немедленно уволен, не заботясь о setMaxWaitTime(900000)
, Это нормальное / документированное поведение?
1 ответ
В LocationUpdatesPendingIntent есть небольшой отказ от ответственности:
// Sets the maximum time when batched location updates are delivered. Updates may be
// delivered sooner than this interval.
mLocationRequest.setMaxWaitTime(MAX_WAIT_TIME);