Android Question Problem with Geolocation

ciginfo

Well-Known Member
Licensed User
Longtime User
Problem with Geolocation
Hello,
My app was working correctly and for a few days it crashes as soon as I call NEW_POSITION. Here part of the code as well as the error message obtained in debug mode. On the smartphone the location authorization is OK and network is OK. I restart the smartphone and still the same crash, even though it was working a few days ago.
An idea ?
B4X:
Sub NEW_POSITION 'Geolocalise
    Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_ACCESS_FINE_LOCATION)
    wait for Activity_PermissionResult (Permission As String, Result As Boolean)
    If Result Then
        GeoLoc.Initialize("GeoLocation")
        GeoLoc.GetLocation
        GeoLoc.geoAddress  '(Ligne 63)
        MyLatitude = GeoLoc.Lattitude
        MyLongitude = GeoLoc.Longitude
        Log(GeoLoc.Address)
        'Affiche
        LblLat.Text = "Lat: " & MyLatitude
        LblLong.Text = "Long: " & MyLongitude
        LblAdresse.Text = GeoLoc.Address
    Else
        Activity.Finish
        StartActivity(Main) 'show the main activity again
        ToastMessageShow("Position non trouvée, Problème de réseau ou GPS", True)
    End If
End Sub

 

TILogistic

Expert
Licensed User
Longtime User
Last edited:
Upvote 0

ciginfo

Well-Known Member
Licensed User
Longtime User
I looked at the links but I don't see at all what I need to add to my code. Can you help me a little more?
THANKS
 
Upvote 0

ciginfo

Well-Known Member
Licensed User
Longtime User
Just like that?
B4X:
Sub NEW_POSITION 'Geolocalise
    Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_ACCESS_FINE_LOCATION)
    wait for Activity_PermissionResult (Permission As String, Result As Boolean)
    If Result Then
        GeoLoc.Initialize("GeoLocation")
        GeoLoc.GetLocation
        GeoLoc.geoAddress  '(Ligne 63)
        MyLatitude = GeoLoc.Lattitude
        MyLongitude = GeoLoc.Longitude
        Log(GeoLoc.Address)
        'Affiche
        LblLat.Text = "Lat: " & MyLatitude
        LblLong.Text = "Long: " & MyLongitude
        LblAdresse.Text = GeoLoc.Address
     [B]   sleep(1000)[/B]
    Else
        Activity.Finish
        StartActivity(Main) 'show the main activity again
        ToastMessageShow("Position non trouvée, Problème de réseau ou GPS", True)
    End If
End Sub
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
If you make more than one simultaneous request?

Test
B4X:
sleep(1000) 'or Sleep(0)
GeoLoc.geoAddress  '(Ligne 63)
 
Upvote 0

ciginfo

Well-Known Member
Licensed User
Longtime User
Ah I understand
It is difficult to test because the crash problem does not occur every day, but probably when the network is not great. So I'm going to test every day and see.
Does Geolocation require network presence all the time or only for 'GeoLoc.geoAddress'.
If I only use 'GeoLoc.Lattitude' and 'GeoLoc.Longitude', is network necessary?
Merci beaucoup
 
Upvote 0

Setlodi

Member
According to your error message, it times out after trying for 4.932716094 seconds. If you're still experiencing problem, maybe increase Sleep to 5000 (5 seconds).
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…