可以使用以下方法开始从 LocationManager 检索通知:
requestLocationUpdates(String provider, long minTime, float minDistance, LocationListener listener, Looper looper)
文档用这些词解释属性:
provider the name of the provider with which to register
minTime minimum time interval between location updates, in milliseconds
minDistance minimum distance between location updates, in meters
listener a LocationListener whose onLocationChanged(Location) method will be called for each location update
looper a Looper object whose message queue will be used to implement the callback mechanism, or null to make callbacks on the calling thread
如果我想开始使用这种方法接收更新,我不能很好地理解类(looper)的行为。
此外,我正在围绕类 LocationManager 创建一个库,并且在执行正常行为之前,我需要做一些其他工作。我需要的是开始接收库的 LocationListener 更新,而不是仅在验证某些条件后才执行正常行为。
为了做到这一点,如果用户开始使用上述方法接收更新,我需要知道如何模拟具有 LocationManager 的行为。
我希望我很清楚。有人能帮我吗?谢谢!