使用requestLocationUpdates用于多个提供 [英] Using requestLocationUpdates for more than one provider
问题描述
(这是关于 LocationManager
类的机器人)。
有没有使用 requestLocationUpdates
的办法,但在某些方面,允许它给我结果最好主动提供每一次?我可以通过它 getBestProvider
的结果,但它总是会从供应商返回的结果,这是行不通的,因为我想到,如果用户打开了GPS的/关闭。
我的code是在后台服务。
有没有使用requestLocationUpdates的一种方式,但在某些方面,允许它给我结果最好主动提供每一次?
没有,但欢迎您注册单独的 LocationListeners
多个供应商。
我可以通过它getBestProvider的结果,但它总是会从供应商返回的结果,这是行不通的,因为我想到,如果用户打开/关闭的GPS
您 LocationListener的
时,它的供应商启用和禁用通知。如果您目前的供应商被禁用,你可能会注册一个 LocationListener的
带后备人员。
(this is about the LocationManager
class in android).
Is there a way of using requestLocationUpdates
, but in some way that allows it to give me results for the best active provider every time? I could pass it the result of getBestProvider
, but then it will always return results from that provider, and it wouldn't work as I expect if the user turns the gps on/off.
My code is in a background service.
Is there a way of using requestLocationUpdates, but in some way that allows it to give me results for the best active provider every time?
No, though you are welcome to register separate LocationListeners
for multiple providers.
I could pass it the result of getBestProvider, but then it will always return results from that provider, and it wouldn't work as I expect if the user turns the gps on/off.
Your LocationListener
is notified when its provider is enabled and disabled. If your current provider is disabled, you might register a LocationListener
with a backup provider.
这篇关于使用requestLocationUpdates用于多个提供的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!