FusedLocationProviderClient.requestLocationUpdates not getting altitudes - android

I'm experiencing some strange behavior with our Android app using Fused location Provider Api.
In some devices this api is not returning the altitudes
I can check it on Moto G 2d generation but our users report the same behavior at least on Moto G 3d generation, Nexus 6 and Moto X Play. In the great majority of other devices altitudes are returning well so I'm pretty sure that my implementation of the Api is correct.
The funny part is that I realized that if I use android.location.LocationManager
, for example, like this
mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 500, 0, locationListener);
the app is starting to receive altitudes, not only on 'LocationListener' subscribed to 'LocationManager' but on LocationCallback of the Fused Location Provider Api as well.
But this breaks the optimization made by Fused location Provider Api and seems silly to use both apis.
I can experience similar behavior if I use both google maps and our app. While using google maps our app is receiving altitudes but when google maps is closed Fused Location Provider Api stops to send altitudes as well.
When I'm talking about not receiving altitudes I mean that location.hasAltitude() == false and location.getAltitude() == 0
This is my implementation to request location updates:
LocationServices.getFusedLocationProviderClient(context);
LocationRequest currentLocationRequest = new LocationRequest();
currentLocationRequest.setInterval(500)
.setFastestInterval(0)
.setMaxWaitTime(0)
.setSmallestDisplacement(0)
.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
fusedLocationProviderClient.requestLocationUpdates(currentLocationRequest, locationCallback);
It seems to me that FusedLocationProviderClient is not turning on some hardware stuff on this devices, so may be a bug on this Api, but I didn't found any one else reporting that, except this similar behavior:
Nexus 6 Fused Location Provider getSpeed returns 0
Thanks.

Since hasAltitude() returns false there are parameters missing to the FusedLocationProvider that would make it possible to provide a confident altitude. This depends largely on the manufacturers setup and devices capabilities which is one of the reasons the Provider exists.
The reason could also be an insufficient GPS-lock or something else but since you could narrow it down to certain devices I would expect that not to be the issue.
You can try (as you already did) other location data sources and check if their results return an altitude, but keep in mind that that might be less consistent. My first try would be the old Location provider.
But there is no way for you to fix the misbehavior of the FusedLocationProvider it is a manufacturer config fail.

Related

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

GPS works better with google maps than my App android

I have an app in android using GoogleMaps API.
When i use google maps, I active gps and it find me so fast.
When i use my app, it takes some seconds, and if I'm in my house, gps dont find me. WHY ?
A short summary of my code:
locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
MyLocationListener = new MyLocationListener();
locationManager.requestLocationUpdates(
LocationManager.GPS_PROVIDER,
7000,
5,
MyLocationListener
);
Thx for answers and sorry for my poor english
EDIT
Thx for answers ! the problem is that i dont want to use network provider. Wifi is exelent, and 3g have a 400 meters error jejeej.
I only want to know, why google maps, using GPS, find me in 1 second with perfect position Although I stay in a house.
Your answer is "use coarse locate". If google maps use network providers befor gps, its impossible he find me so fast. :(
GPS is using satelites, When you are indoor it can't get the signal from the satelites hence it can't find location (can't get a fix).
The GPS needs signals from at least 4 satelites to get a proper fix, that usually takes a few seconds, once you already have a fix you can maintaine it very easly. therfore if you are using google maps it will get you a fix faster.
To get a better understand on how GPS works, check this link
You might want to use different location approachs for getting location indoor (coarse location could be the answer). I would also consider using the fused location by Google play services, it gives you a wrap up on the location providers and get you location based on what avilable at the time (meaning GPS, coarse - wifi or network).
You should try using Coarse locates for a quick locate followed by a fine locate to have a more accurate location. The coarse locate is usually very fast, while the fine one takes more time.
Basically, the idea is to do multiple locates and overriding the less accurate ones by the newer and more accurate locates.
You can find more info on the Android dev doc: http://developer.android.com/guide/topics/location/strategies.html
EDIT: if Google Maps is able to find you so fast, it is because you are not moving and they use the knowledge of the last location. Please read the above link that gives a lot of useful information for Location strategies (and it works very well).

I do not get geofence notifications

I'm writing an Android application that notifies the user when he enters a specific region. For this I used the Geofence API from Android.
I have tried Google's GeofenceDetection sample, and The application does not get notified at all.
I call addGeofences, and receive onAddGeofencesResult notification with statusCode 0, so all seems to be working fine, but when I walk (or drive) in and out of the geofence (with radius 5m or 50m) nothing happens.
I use Nexus4 and Eclipse - both updated to latest versions.
Why don't I get geofence notifications?
I've found that the GeoFencing API never intelligently retrieves locations from the GPS hardware. The GeoFence API will observe the most accurate location available from the OS or if no location is currently available, it will cause a location to be calculated from Wifi / Cellular. (which sucks because cellular is wildly inaccurate and wifi is often unavailable)
So to get at all responsive or accurate results out of the Geofencing API you have to set up your Geofences and then poll the GPS hardware on an interval, not even doing anything with the result received, so that under the surface you are providing worthwhile data to the OS.
This behaviour is not documented- thanks Google!

Android Geofencing API bug with GPS?

I found some people reporting a similar issue but no answers for that.
I'm using the android Geofencing API released in Google I/O 2013. I followed the "Creating and Monitoring Geofences" lesson and its sample.
When I use this API with wi-fi coverage it works perfectly. The problem is when I'm outside. It never used the GPS to track the location however the GPS sensor is turned ON.
The only way I found to manage this is by forcing the app to use the GPS by calling
mLocationClient.requestLocationUpdates(mLocationRequest, mLocationListener);
and with mLocationRequest with a priority of high accuracy
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
By forcing the GPS usage it works good but I need to stop its updates programmatically.
My questions are:
1) Shouldn't the API be aware of when to use or not the GPS sensor?
2) Does the Geofence radius affect the sensors that the API use?
3) For those who might got it work properly: does the GPS sensor "blinks" when it's the only sensor turned on ?
I'm struggling to get more documentation for this API, so I would like to know your experience.
Thanks in advance ;)
did you got this up and running? I tried the same sample but i got it running properly on when i turnned the google maps app on.
Thanks
MArlus

GPS Location returns zero speed always

I have code that successfully gets location updates from multiple providers and filters them to give a current best estimate.
I added code to check for the returned Location.hasSpeed() and .hasBearing() values to do some bearing related calculations when the user is actually moving.
It all works fine on a Huawei Sonic running 2.3.3, but on the Google Nexus S running 4.0.4 the GPS provider's Location always returns false for .hasSpeed() and 0 for .getSpeed().
When I register my location listener, the GPS provider returns true for .supportsSpeed() but it never returns the speed in a Location even when the accuracy is down to 30m and it is physically moving (in a car, on the dashboard for max reception, screen on).
Is there some difference from 2.3.x to ICS 4.x?
Do I have to implement my own speed calculation even when the provider reports support?
Google Nexus S has history of problems with GPS. I don't think that it's specifically related to ICS. Have you tried Factory data reset the phone and then retry it?

Categories

Resources