Hi,
I use GNSS for the first time. I got this error:
My service is:
Can someone help me?
Kind regards,
André
I use GNSS for the first time. I got this error:
B4X:
java.lang.Exception: Sub gnss_locationchanged signature does not match expected signature.
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:223)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
at anywheresoftware.b4a.gnss.GNSS$1.onLocationChanged(GNSS.java:84)
at android.location.LocationListener.onLocationChanged(LocationListener.java:63)
at android.location.LocationManager$LocationListenerTransport$1.operate(LocationManager.java:3247)
at android.location.LocationManager$LocationListenerTransport$1.operate(LocationManager.java:3244)
at com.android.internal.listeners.ListenerExecutor.lambda$executeSafely$0(ListenerExecutor.java:127)
at com.android.internal.listeners.ListenerExecutor$$ExternalSyntheticLambda0.run(Unknown Source:8)
at android.os.Handler.handleCallback(Handler.java:984)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loopOnce(Looper.java:238)
at android.os.Looper.loop(Looper.java:357)
at android.app.ActivityThread.main(ActivityThread.java:8109)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:957)
My service is:
B4X:
#Region Service Attributes
#StartAtBoot: False
#ExcludeFromLibrary: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim LatLonTrace As Location
Dim LatLonRoute As Location
Dim LatLonKm As Location
Dim Route As List
Dim RouteTijd As List
Dim OpnemenRoute As Boolean
Dim GeredenKm As Float
Dim LastKnownLocation As Location
Dim GNSS1 As GNSS
Dim gpsStarted As Boolean
End Sub
Sub Service_Create
If(LatLonTrace.IsInitialized=False) Then LatLonTrace.Initialize
If(LatLonRoute.IsInitialized=False) Then LatLonRoute.Initialize
If(LatLonKm.IsInitialized=False) Then LatLonKm.Initialize
If(Route.IsInitialized=False) Then Route.Initialize
If(RouteTijd.IsInitialized=False) Then RouteTijd.Initialize
If(LastKnownLocation.IsInitialized=False) Then LastKnownLocation.Initialize
If(GNSS1.IsInitialized=False) Then GNSS1.Initialize("GNSS")
Service.AutomaticForegroundMode=Service.AUTOMATIC_FOREGROUND_NEVER
Starter.Lock.PartialLock
End Sub
Sub Service_Start (StartingIntent As Intent)
Service.StartForeground(999,RemoveIcon)
StartServiceAt(Me, DateTime.Now + 15 * DateTime.TicksPerMinute, True)
If(Starter.GPSLoc Or Starter.GPS) Then StartGNSS
Log("Heartbeat: "&DateTime.Time(DateTime.Now))
End Sub
Sub Service_TaskRemoved
'This event will be raised when the user removes the app from the recent apps list.
End Sub
'Return true to allow the OS default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
Return True
End Sub
Sub Service_Destroy
Log("GPSTrack Destroyed")
If gpsStarted Then
GNSS1.Stop
gpsStarted = False
Route.Clear
RouteTijd.Clear
End If
Starter.Lock.ReleasePartialLock
StartService(Me)
End Sub
Public Sub StartGNSS
If (Starter.rp.Check(Starter.rp.PERMISSION_ACCESS_FINE_LOCATION)=False) Then
Log("No permission")
Return
Else
If gpsStarted = False Then
Log("GPS Started")
GNSS1.Start(0, 0)
gpsStarted = True
End If
End If
End Sub
Sub RemoveIcon As Notification
Dim ic As Notification
ic.Initialize2(ic.IMPORTANCE_LOW)
ic.Icon="empty"
ic.Sound=False
ic.SetInfo("","",Null)
Return ic
End Sub
Sub GNSS_LocationChanged (Location1 As Location)
Dim DatumTijd As String
Log("CheckLocationChanged: "&DateTime.Time(DateTime.Now))
Log("Afstand: "&Location1.DistanceTo(LatLonTrace))
LastKnownLocation=Location1
End Sub
Sub SendLatLon(Location1 As Location)
Dim HTTPLocatie As HttpJob
Log("Registreren locatie")
End Sub
Can someone help me?
Kind regards,
André