为什么requestLocationUpdates立即在Receive上触发?

时间:2018-10-02 11:06:15

标签: android android-location fusedlocationproviderapi android-fusedlocation fusedlocationproviderclient

当我执行这样的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 个答案:

答案 0 :(得分: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);