我有一个带有 LocationFused API 实现的简单应用程序:
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;
}
当应用程序部署在设备上时,我应该期望每 60 秒收到一批位置,如 setMaxWaitTime 方法中指定的那样,但这仅在部署后第一次发生(我在 1 分钟后收到 7 个位置),然后我开始接收 1每 5 秒定位一次。
为什么 setMaxWaitTime 只工作一次?