Android Question Fused Location Provider shows altitude = 0?

HappyDad

Member
Licensed User
Longtime User
I am using the following code to get the approximate location.
In LocationChanged sub, the latitude and longitude are fine, but the altitude is 0, which is not right.
I asked for PERMISSION_ACCESS_FINE_LOCATION.
But in the Fused Location Provider code, I asked for PRIORITY_BALANCED_POWER_ACCURACY. Is this the reason?

B4X:
myFLoc.Connect

Sub myFLoc_ConnectionSuccess
    Dim LocationRequest1 As LocationRequest
    LocationRequest1.Initialize
    LocationRequest1.SetInterval(1000)
    LocationRequest1.SetPriority(LocationRequest1.Priority.PRIORITY_BALANCED_POWER_ACCURACY)
    LocationRequest1.SetSmallestDisplacement(0)
    myFLoc.RequestLocationUpdates(LocationRequest1)
End Sub
 

DonManfred

Expert
Licensed User
Longtime User
From this documentation, By default, Location's latitude and longtitude are 0 and the location has no bearing, altitude, speed, accuracy or extras.
So you can only get the altitude if it is available. Not all location have an altitude.

You can use the hasAltitude() method that return a boolean results to know if the location has an altitude.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…