Hello, please apologize my english, i am doing an B4A app and i need to track use gps coordinates.
I did it in the past without problem, but now i am getting an error exactly in this line:
I added the standard starter module to my app...
i added this 2 lines in the manifest (dont know if really needed);
My targetSdkVersion i set to "29".
In my main module i have this lines (related to gps):
And when i need to check if GPS is ok, i use this:
If "location"is disabed on my phone, no problem... when i activate location then that line i commented (Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_ACCESS_FINE_LOCATION)) gives an error.
I know there is a lot of code about gps, but i cant figure out what is the problem...
Can you please help me? Thanks.
I did it in the past without problem, but now i am getting an error exactly in this line:
B4X:
Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_ACCESS_FINE_LOCATION)
I added the standard starter module to my app...
i added this 2 lines in the manifest (dont know if really needed);
B4X:
AddManifestText(<uses-feature android:name="android.hardware.location.gps"/>)
AddPermission(android.permission.ACCESS_FINE_LOCATION)
My targetSdkVersion i set to "29".
In my main module i have this lines (related to gps):
B4X:
Public Sub LocationChanged(Location1 As Location)
LaLati = Location1.Latitude
LaLong = Location1.Longitude
End Sub
Sub GpsStatus(Satellites As List)
If Starter.GPS1.GPSEnabled=False Then
LaLati=""
LaLong=""
End If
End Sub
Sub Activity_PermissionResult (Permission As String, Result As Boolean)
If Permission = Starter.rp.PERMISSION_ACCESS_FINE_LOCATION Then
If Result Then CallSub(Starter, "StartGPS")
End If
End Sub
Sub Activity_Pause (UserClosed As Boolean)
CallSub(Starter, "StopGPS")
End Sub
And when i need to check if GPS is ok, i use this:
B4X:
If Starter.GPS1.GPSEnabled = False Then
ToastMessageShow("PASO 1: Active la Ubicación en su dispositivo" & CRLF & "PASO 2: Verifique que el Modo de Ubicación no esté en 'Ahorro de batería'" & CRLF & "PASO 3: Otorgue permiso a esta aplicación (ingrese a 'Permisos en las apps')", True)
StartActivity(Starter.GPS1.LocationSettingsIntent) 'Will open the relevant settings screen.
Else
Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_ACCESS_FINE_LOCATION)
Wait For Activity_PermissionResult (permission As String, Result As Boolean)
If Result Then CallSubDelayed(Starter, "StartGPS")
End If
If "location"is disabed on my phone, no problem... when i activate location then that line i commented (Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_ACCESS_FINE_LOCATION)) gives an error.
I know there is a lot of code about gps, but i cant figure out what is the problem...
Can you please help me? Thanks.