【问题标题】:Why requestLocationUpdates fire immediatly onReceive?为什么 requestLocationUpdates 会在接收时立即触发?
【发布时间】:2019-03-07 12:10:23
【问题描述】:

当我像这样执行 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)。这是正常/记录在案的行为吗?

【问题讨论】:

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


    【解决方案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);
    

    【讨论】:

    • 感谢 Melix,但越早意味着什么?立即(就像我注意到的那样),1 分钟? 10 分钟?事实上,对于第一次调用 requestLocationUpdates 来说,我想知道的是他们所说的“更快”是什么意思
    猜你喜欢
    • 2017-02-20
    • 2014-03-23
    • 2013-06-23
    • 1970-01-01
    • 2016-06-11
    • 2021-10-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多