简体   繁体   English

LocationManager GPS_PROVIDER花费太多时间

[英]LocationManager GPS_PROVIDER taking too much time

I'm using LocationManager.GPS_PROVIDER to get the current location of the user but it's taking too much time to return the location, should I use the NETWORK_PROVIDER over GPS_PROVIDER ? 我正在使用LocationManager.GPS_PROVIDER来获取用户的当前位置,但是返回位置花费了太多时间,我应该在GPS_PROVIDER使用NETWORK_PROVIDER吗? Or there is something new and better to get the current location of the user to trace a destination route ?. 还是有一些新的更好的方法来获取用户的当前位置以跟踪目标路线?

locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 1000, 10f, object : LocationListener{...}

It is suggested to use fused location provider. 建议使用融合的位置提供程序。 More details here . 更多细节在这里

Using the GPS_PROVIDER does take a little while to fetch location updates probably because of its accuracy in my opinion. 我认为使用GPS_PROVIDER确实需要一些时间来获取位置更新,可能是因为其准确性。 You could also instead of wanting a new location request an older location that's slightly stale (Say for example 2 mins old) and that would be almost ready to use. 您也可以不希望新的位置请求一个较旧的较旧的位置(例如说2分钟),并且几乎可以使用了。

I would, however, recommend NOT using Location Manager at all and since it is depreciated and was replaced by a much cleaner and performant Fused Location Provider API . 但是,我建议完全不要使用位置管理器,因为它已被贬值,并且已被更干净,性能更强的Fused Location Provider API取代。 It has support for last location, location updates and it's the currently the method Google recommends. 它支持最后的位置,位置更新,这是Google目前建议的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM