Android gps location real accuracy is bad - android

I get location in LocationListener configured with following code:
LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 60000, 5.0, locationListener);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 60000, 5.0, locationListener);
Locations which I get are innacurate very often. Accuracy in location for "gps" provider is about 10-20 m, but in real it can be about 500 m. And in native Android application Google Maps I see my location accurate enough.
I have suspicion that Google use some another API. Is there present another way to get locations in Android?
OS: Android 4.4
Smartphone model: Doogee Voyager 2 DG310

Google apps use a proprietary provider called "Fused Location Provider" (read more here). This provider still uses the network and GPS providers present in the background.
The first location fix from network provider will most of the time be grater than 1000 m in accuracy because it comes from a BTC (cell tower). After a few seconds it should drop to around 20-50 m accuracy based on Wi-Fi. The GPS provides locations usually with max accuracy 20 m but this can increase when you're in a densely populated area with tall buildings and bad connection to GPS satellites.
I recently discovered the Smart Location Library which should provide easy access to either GPS, network or fused providers in combination with Activity Recognition to decrease battery drain.

Related

OnLocationChanged not fired on some devices

I'm aware that there's a lot of 'similar' questions, but none of them provided a useful answer.
I am trying to listen to location updates, both from network and GPS. The LocationListener initialization is pretty standard:
locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 15000, 0, locationListener);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 15000, 0, locationListener);
I tested it on two devices, Samsung Galaxy S4 (SM-N910F) and LG G Flex 2 (H950). On the first device onLocationChanged is called as expected (only from 'network' provider), while the event is never fired on the second.
Both devices are set on 'High Accuracy' mode. I tried the second device on Wi-Fi as well as on 4G LTE connection. Since I use Google Maps API, I can clearly see the user marker moving on map, yet the event is never called.
Any idea why onLocationUpdated is never called on the second device?
Additionally, I read that GPS takes a very long time to fix. Is there any point in requesting updates from the GPS provider?
Thanks!
May I suggest you start using Google Play location APIs.
The Google Play services location APIs are preferred over the Android
framework location APIs (android.location) as a way of adding location
awareness to your app. If you are currently using the Android
framework location APIs, you are strongly encouraged to switch to the
Google Play services location APIs as soon as possible.
https://developer.android.com/training/location/index.html

Android location accuracy

I have the following code implemented to retrieve location values on Android:
mLocationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, this);
On Android 2.3 and 4.1 this works great and returns updates at 180 samples per hour with a resolution down to 100m or less.
However, on Android 4.3 something has changed so this only provides updates at 5 samples per hour and a resolution at 2km. I haven't tested on later versions.
What has changed? Is it possible to return to the old accuracy levels again? I don't want to force GPS for power reasons. The app has ACCESS_COARSE_LOCATION permissions.
I have been testing this on a Samsung S3 if it makes a difference.
Use Google's LocationServices API instead:
https://developer.android.com/training/location/receive-location-updates.html
LocationManager.NETWORK_PROVIDER do not provide accurate location it provides you the location according to the cell tower you connected,sometimes it provides location with accuracy of 100m sometimes with 2-3km,if you do not want to get the location from gps due to power reasons i would suggest you to use fused location provides as this is an efficient and effective way to get the location on android and Google also recommends this,you can read more here in this example http://www.kpbird.com/2013/06/fused-location-provider-example.html

How to get more location data within 20 second duration by requesting to NETWORK_PROVIDER?

Hi I have used the below code to get the location information from the network provider.
mLocationManager.requestLocationUpdates(
LocationManager.NETWORK_PROVIDER, 0, 0,
mLocationUpdatePendingIntent);
After 20 second I removed the location update. But with in 20 second am getting only 2 location data. Even connected with WiFi I am getting only 2 location data. If connected to WiFi I am getting the better accuracy location data. But still 2 location data.
I tried Location Request With GPS_PROVIDER, I am getting around 30 different location data.
Location request With NETWORK_PROVIDER in sony mobile with Aircel sim, I am not getting any location data in 20 seconds duration.
And also Location request With NETWORK_PROVIDER in samsung mobile with Airtel am getting only 2 samples in 20 seconds duration.
Location request With PASSIVE_PROVIDER never returns me any location data. I have used the Google Map apps. Still passive provider returns nothing.
I don't want to use the Fused location api. I need to use the Location manager. So How to get more location data with the help of NETWORK_PROVIDER. And also in sony mobile I am not getting any location data when requesting location with NETWORK_PROVIDER.
Please help me on this.

Getting Speed using Google Play Location API

I am using fused location provider from the new GooglePlay API(LocationClient class). But the method Location.GetSpeed() is not returning correct speed (shows 0). I read that I have to use LocationManager class to get the speed, but when I tried LocationManager a new problem occured. The location manager NetworkProvider is not working, here is a thread with the problem http://code.google.com/p/android/issues/detail?id=57707 .
So what is the best way to get the speed of movement. I tried calculating it distance/time but it is not accurate..
The only sensor that delivers speed is GPS.
Wlan and GSm cell Tower locatining cannot deliver speed.
If you need speed, you have to make sure that GPS is used exlusivley as Location Provider.
You cannot use NetworkProvider for that task.
If speed is an important requirement, which has higher priority than battery consumption you have to stay with GPS Provider only. You have to avoid the fused location provider.
Its technically not possible to have speed without GPS.
I also encountered this problem when I was using Google Play Location API,
I hope this can help.
It returns 0 because your device cannot get a lock on the GPS, or cannot connect to the GPS.
I tried to get the speed using an older lenovo device and it returns 0 because it cannot lock on a gps.
I tried using a samsung galaxy nexus and it returned my speed(has a better GPS sensor).
The GPS sensor in your phone might not be good or you are in an area that has a weak GPS signal such as inside a house or building.
Even if you use the locationManager to get the speed if you are not connected to the gps, your getSpeed will still return 0.

Why couldn't I get GPS coordinates in a remote place?

I went on a trip somewhere remote and I didn't have mobile access but I thought that my GPS would work anyway since a GPS transmitter just relies on satellites. I have the following code to get GPS location:
mlocManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
mlocListener = new MyLocationListener();
mlocManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, mlocListener);
I tried to record my GPS coordinates and they ended up empty.
Is there something that I am not doing correctly or that I don't understand?
What can I change so that my phone can record raw GPS data with or without network access?
A GPS receiver needs to have several GPS satellites above the horizon, in order to receive the signals it uses to calculate its longitude and latitude. Each satellite broacasts this ephemeris information as part of its data stream, but a standalone receiver might take several minutes to scan through the available satellite frequencies from a "cold start" (where cached ephemeris information is out of date or incorrect for the current location).
GPS receivers on cell phones often implement "carrier assisted GPS", where the cellular network pushes the up-to-date GPS satellite ephemerides out to the handsets from time to time, so the phone already knows which satellites are in view at any given time/location without having to do a search.
If you don't have cellular network access, your phone might be programmed to fall back to a satellite-by-satellite search for usable signals, and might take longer to get its first GPS fix (if it can get one at all without carrier assistance).

Categories

Resources