Is there an alternative to Location Client (Google Play API)?
Asked Answered
H

1

7

I work on an app that uses location data, and it needs to work in China. Android devices sold here largely don't have Google Play API installed at all and the only way is to root the phone to install it. So I'm stuck with LocationManager which works far worse than LocationClient (part of Google Play API).

My issue is that LocationManager, when reading from GPS_PROVIDER, frequently cannot connect to enough satellites (in China) and there's occasional significant time gap between fixes. When reading from NETWORK_PROVIDER, I can get more frequent fixes, however accuracy ranges from 30 to 500. Nowhere near LocationClient API quality.

The app is supposed to monitor your movement through streets frequently, eg. update every second (high battery use, not a problem to my client) and do something when you reach certain locations.

If I use Google Play API and LocationClient, it's really working well. But that's only on Nexus4 or some non-Chinese Android device.

I'm asking if anyone know a library that can give better results than straight forward use of LocationManager, or a solution how to use LocationManager to improve results?

Hysteroid answered 4/4, 2014 at 11:24 Comment(4)
github.com/novoda/NovocationWillable
Why not write your own implementation using Location Manager developer.android.com/guide/topics/location/strategies.htmlBename
Also android-developers.blogspot.com/2011/06/…Bename
@MuhammadBabar it's exactly the same as Google's example in SDK. Even their Map example has same issue (in China).Leanto
A
2

GPS isn't working well likely due to lack of required GPS metadata (ephemeris and almanac data), or due to slow acquisition of this metadata. For the latter case, in most countries GPS ephemeris and almanac data is available through network sources. If not, the GPS chip has to download that from the satellites which can take 5-20 mins (the fastest time being when the initial data stream provided enough info for the GPS chip to acquire a lock). I am not familiar with the availability of this data in China through network sources, but it sounds like it is not widely available from what your are experiencing. (Keywords to google for more info: SUPL, ephemeris, alamanac).

When GPS is not available or slow to get a lock, network geolocation is the fallback, which uses wifi points and cell towers to triangulate a position. This requires an internet service for the device to send the APs + towers it sees, and the service sends back a location. Accuracy levels of 30 to 500 meters are quite good for this.

(BTW, a network geolocation position is also used to 'seed' the GPS chip to help it to get a faster lock)

Network geolocation on Android is typically provided by a google web service, but the phone can be configured to use other providers by carriers.

You can avoid using Google (Google Play or Google's network geolocation server) or the built-in network location service by trying Mozilla's free-for-use network geolocation service: https://location.services.mozilla.com/

You need to request an API key: https://location.services.mozilla.com/api For a code sample: this app both contributes data and is a client for the service: https://github.com/mozilla/MozStumbler

I doubt this will get better network geolocation accuracy for the area you are in, since you are already getting good results, but perhaps it is worth investigating.

Anelace answered 4/1, 2017 at 22:58 Comment(2)
Thanks for your answer! I was not aware Mozilla has geolocation API, will give it a shot see how it works in China.Leanto
Beware of the Mozilla Geolocation API: The service is currently provided as-is, free of charge, without any guarantee on availability, accuracy of results or continued existence. We don't offer any commercial plans for the service and have no plans to provide such.Polecat

© 2022 - 2024 — McMap. All rights reserved.