Android Question Google maps - point to point map

luke2012

Well-Known Member
Licensed User
Longtime User
Hi everyone,
in my app I put a nice "button" / icon that should open the path in Google Maps from point A to point B.
If I understand correctly, point A (departure) is detected via location provided by the gps / network and point B (destination) is set as a parameter.
I specify that it is the first time that I interact programmatically with Google maps and I started from the code of a post I found in the forum (which I then customized):

B4X:
Sub btnNavigate_Click
    #if B4A
   
    Private i As Intent
    Private city As String
    Private province As String
    Private street As String
    Private HouseNumber As String
    Private MapURL As String
    
    city = "Porto Viro"
    province = "RO"
    street = "Piazza della repubblica,"
    HouseNumber = "1"
    MapURL = "http://maps.google.com/maps?saddr=" & city & "," & province & ",&daddr=" & street & " " & HouseNumber
       
    i.Initialize(i.ACTION_VIEW, MapURL)
    i.SetComponent("com.google.android.apps.maps/com.google.android.maps.MapsActivity")
    StartActivity(I)

    #End If
   
    #if B4i
    #End If
End Sub

I do tests to see if it works correctly on 2 emulated phones with 2 different Android versions and this is the result:


I state that from where I live to the city indicated there are almost 300 km.
On the smartphone on the left (the exact same app and the same exact destination address) it says that it takes 4 minutes to go from Saronno (VA) where I am currently to Porto Viro (RO).
4 Minutes maybe with startrek's teleport

Then not happy I try on my real smartphone that has an Android 10 and it tells me something else still different from the first 2 :



He says: 5 hours - 308 km and this is correct.
I was wondering if there is a rationale for which to do this, perhaps because on the 2 emulated devices there is no correct detection of the starting point position or the default address (home) of the user is not set?
So is it only on emulated and incorrectly configured devices that this happens? On all real devices correctly configured (GPS position) it should work correctly. Correct?
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…