I've been testing android's new Location API's for a few weeks. In general they work quite well, however, the new Location provider frequently loses the plot.
Specifically, I wire up an example based on the receive location updates example. It works correctly, and the location updates are received as expected.
The problem seems to be with the Fused provider itself. In some areas (notably around my home) it completely gets lost. It will suddenly think I am kilometers away from where I am. Around where I work (which is a more built up area) it is much more accurate and always reasonably close to where I actually am (in Balanced mode).
I have made many attempts to fix this, including switching to PRIORITY_HIGH_ACCURACY when I suspect it is in error, or using the older LocationManager to try get a GPS fix to establish where I really am. But nothing seems to help too much. I suspect Google has bad data on where certain mobile towers of WiFi hotspots are around my home, and when it connects to certain towers is suddenly jumps a few km from the true location. It's very annoying and will interfere with the Geofence API also. Any advice on how I can fix this?
Can you just ignore the location updates that are inaccurate? This code was released at Google IO 2013 I think, so it might still have some bugs.
(I am experiencing the same thing as you. Rural area, the Fused Location provider is giving me locations all over the place)
There is bad data about some WIFI APs from time to time, and these tend to fix themselves after a while. A clue to what's happening to you can be found in the accuracy returned. If when it goes to the wrong place, the accuracy is a large number (hundreds of meters), that implies the fused location provider is using a cell location. It may mean there aren't a lot of APs where you live, and that you can only get a wifi location once in a while (or once in a while you can't get a wifi location). The FLP should get better at avoiding these jumps over time as algorithms improve.
If the bad location you get has a small accuracy (around 30 meters), that implies it's a wifi location, and bad AP database information probably explains the issue.
Related
At the moment I'am working on a application that is using the location of a phone. Before I started with building my application I did some research about how the phone location is working.
The conclusion is that a mobile phone can talk to a GNSS satellite and then determine the location of the device (in real life there is much more technology behind this, but I will leave that aside for the sake of simplicity). However, I noticed that when we talk about Geographic locations, many people talk about a GPS location. But why is it called a GPS location? Because during my research I also read that the latest phones are now equipped with a multi-GNSS system that allows them to talk to different GNSS systems and use all this data together to determine a location even more accurately. However, this means that not only the GPS data is used, but also data from GLONASS.
So why is it always called a GPS location? Or is my theory wrong?
I already did some research about this topic on the internet but I cant find any information about this topic.
Because the average person doesn't care about details. GPS was the first major positioning satellite system you could use to get location. So people called it the GPS location. When other systems came up, people kept using the old name because they were used to it, and because they weren't technical enough to care about the difference. THat's why you still tape TV shows when recording digitally, all acetompinophine is called "Asprin", the save button is still a floppy disk, and my mother still calls any video game system "playing Nintendo". If you're talking to professionals in the field where the different satellite systems matter, they'll use more specific terminology. Everyone else will still say "GPS".
I have an android app that uses LocationManager to get geolocation fixes, using either fine (GPS) or coarse (network/wi-fi) location, and I need to know where any specific location fix came from.
I can use
if (LocationManager.GPS_PROVIDER.equals(location.getProvider())){...
to determine that the fix was from GPS
and
if (LocationManager.NETWORK_PROVIDER.equals(location.getProvider())){...
to determine that it was from either a mobile network or from wi-fi, but I don't know which.
My problem is that the app is designed to be used on trains, and train wi-fi doesn't always give the right position (I once travelled from London to Paris on Eurostar, and throughout the journey the geolocation told me that we were at Paris Gare du Nord - even when the train was at London St Pancras!)
Does anyone know a way of telling LocationManager to ignore wi-fi and give me only locations from my mobile network or GPS? If that isn't possible, is there at least a way to tell whether a coarse location came from a mobile network of from wi-fi?
I think I have stumbled across the answer to my own question when looking for something else. I found this statement:
Applications cannot specify the exact location sources, such as GPS, that are used by the LocationClient. In fact, the system may have multiple location sources (providers) running and may fuse the results from several sources into a single Location object.
here:
https://developers.google.com/android/reference/com/google/android/gms/location/LocationRequest
Looks as if I can't do what I want. If anyone knows a way, please let me know.
I am developing an app in Android that reports location to a server, and I was wondering to implement the new released Fused Location API, made by Google. Testing it, indoors and with setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY)
instantly takes networks providers to get location. So, my question is, what see Google in a few seconds to determine that gps is not a good option? I know that gps provider doesn't works properly indoors, but in my office sometimes (it takes an average of 10 secs) it works. Thanks
Well the library itself is not open-source, but I'm sure we can agree on how it does what your describe above:
If the GPS provider is disabled, or if the signal is too weak, or if the fix takes too long, then it returns the last known location and/or the network provider's location.
Seems reasonable. I guess the network provider serves as a fallback to the GPS provider in PRIORITY_HIGH_ACCURACY if GPS is not satisfying.
EDIT
Actually, the documentation says:
PRIORITY_HIGH_ACCURACY
This will return the finest location available.
It does not say it will only use GPS or prioritize GPS at all. It will just return the finest location, which is not always GPS, as #cYrixmorten pointed out: in urban areas, wifi spots are often more accurate.
I have make an android application which help us to get GPS Location using A-gps in my android phone. I am getting latitude and longitude successfully in Metro Cities of my country, but when I am going to some forest area,GPS do not get location and for this I need to run GPRS of my phone,after running google map once in my phone ,GPS successfully gets latitude and longitude even if I closes my internet connection or remove sim card from my phone. But since I do not want to use google map, what should I do now and why it is happening?? Any help will be appreciable
It takes a long time (several minutes) to get the GPS location with high precision. However, if you enable network based location (e.g. cell tower, WiFi), it's way faster but with lower precision.
As a result, you should listen to all the providers with LocationManager, and figure out which provides the best location. Or, if your app targets Android 8 and above, you can use the Location APIs provided with Google Play Services, which hides the details as using LocationManager directly.
First make sure that it is not the fault of your phone or its operation system version.
Download a well working known GPS App, look if they get a GPS signal without internet.
Place it under very good cointions: free view to sky, outside dense city, at least an open place.
You should get a signal within one minute, maybe if the phone has a poor built-in GPS antenna, a bit more, wait some minutes.
If the well working foreign app still don't get GPS it's an Operating system bug.
If you get one, then it´s your fault, and it is worth for further investigation.
*first check your GPS working or not properly with **ANDROITS GPS TEST*.
if it finds and fixes satellite do not worry. as AGPS is fast , standlone GPS needs to have much more time to fix on its own especially in city as many radio waves disturbs GPS fixure.
better first fix with AGPS and then you can turn off data or internet, still it will work as it already had its location and satellites fixed.
with standlone GPS it takes huge time and battery.**
If your phone use GPS h/w to get the location information, it don't require any internet connection. It should be able to get the location fix using GPS without the help of internet. But it may take some time to get the location fix.
You can install the this free app from play-store to test the GPS of your phone : "TestYourGPS".
https://play.google.com/store/apps/details?id=com.eorsavik.testyourgps
When moving a big distance, like to another city, with the GPS off, it takes very much time for it, when turned on, to get the first correct point.
So if by example I register to the gps provider, it could take up to 10 min until the first onLocationChanged call.
The network provider will respond faster, but is less accurate.
Is there a way to help the gps provider? To give it an approximate location (the one from the network provider), so it can find my location faster?
I think that google maps made some kind of optimisation, because their app finds my location faster than my basic app, that only register to the gps provider.
Any idea how I could accelerate the process of obtaining my location with decent accuracy ( <30 m) ?
You are right that if you move a long way with the phone switched off, then it can take a long time to get a satellite fix. This is where AGPS helps. The 'A' stands for 'assisted' which is very much carrier and handset dependent in its implementation. In essence it gets an approximate location from cell towers or from public WiFi like coffee shops and then downloads ephemeris and almanac data which tell the phone which satellites are likely to be overhead at that time in that rough location. The phone can then start listening on the frequencies corresponding to the visible satellites first. This should speed up the time to first fix.
Common practice is to use WiFi SSIDs or the location of the cell tower you're registered with to look up your current location via providers like WeFi or Skyhook. Google uses its own service for that (and sees that no one else does).
Another method would be, in case your smartphone has a barometer, to look up the air pressure and try to pin it down to a location. While all these methods can theoretically be used offline, it is easier to fetch the data from the internet.
Also note that inaccurate NTP settings on the phones may lead to longer GPS search times.
Is there a way to help the gps provider?
NickT has answered this, but the android phone has to call the AGPS. In your app you cannot controll that.
I think that google maps made some kind of optimisation, because their
app finds my location faster than my basic app, that only register to
the gps provider.
This should not be the case, probaly you are doing something wrong, or the google app can enable assisted GPS. Try to compare with other android GPS apps (e.g compare with Motion-X-GPS)
it could take up to 10 min until the first onLocationChanged call.
Normally this is far too long, either your phone is known to have a weak GPS quality, or the device did not have free view to open sky. Even without assisted GPS, after 45 seconds, you should have a valid GPS position (asuming free view to open sky).
But this situation can happen, either the first time you use GPS on your device, or when you fly by airplane to a location far away to your last GPS position.
On my iphone i rarly saw such a situation when another GPS app was somehow disturbing, after a reboot of the device the GPS was immedeatly valid.
Again check if it is the fault of your app, by comparing if other apps needs 10 minutes too. (It could be your fault, when you wait to recieve an accuracy <30m while other apps would take the first valid position they get.
If google needs 10 minutes, too, then you could do nothing on that phone, except to expose it to good view to sky.
(Inside an urban canyon it's more difficult to obtain a valid first fix, then on an big place.)