我希望每隔一定时间获取一个硬定位信息和一个软定位信息,如果用户移动了一定的距离。我已经使用以下代码进行测试(尝试使用更大的参数进行测试),但它并没有真正返回定期的位置信息。当请求开始时,它会立即返回一个位置信息,然后有时会在几分钟后返回1个位置信息,但是之后长达一小时都不会返回位置信息。
LocationRequest locationRequest = LocationRequest.create();
int priority = PRIORITY_BALANCED_POWER_ACCURACY;
locationRequest.setPriority(priority);
locationRequest.setInterval(localInterval); //set to 6 minutes
locationRequest.setFastestInterval(localFastestInterval); //set to 3 minutes
locationRequest.setSmallestDisplacement(smallestDisplacement); //set to 10 meters
locationRequest.setNumUpdates(numUpdates); //set to Int.MAX_VALUE
locationRequest.setExpirationDuration(expirationDuration); // set to Long.MAX_VALUE
LocationServices.FusedLocationApi.requestLocationUpdates(locationClient, locationRequest, pendingIntent);
如果将位移设为0,则会定期接收位置更新。你知道是怎么回事吗?