简体   繁体   中英

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 ? 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. 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.

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 . It has support for last location, location updates and it's the currently the method Google recommends.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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