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.