Android Question Callsub from a Service

Declan

Well-Known Member
Licensed User
Longtime User
I have a FirebaseMessaging Service that receives data.
I then parse the data
I must now call a Sub in Main
I have tried:
Code: Copy
CallSubDelayed(Main,"LoadMap").
I receive the following error:
Code: Copy
java.lang.Exception: Sub loadmap signature does not match expected signature.
What is the correct syntax?
 
What is the correct syntax?
How can we know? YOUR defined the signature of this sub, not we!

How is your current signature of this sub?
 
Upvote 0
B4X: Copy
Sub LoadMap(Lat As String, Lon As String, Volts As String, deviceID As String)
    pnlMap.Visible = True
    Wait For MapFragment1_Ready
    gmap = MapFragment1.GetMap
    rp.CheckAndRequest(rp.PERMISSION_ACCESS_FINE_LOCATION)
    Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
    If Result Then
        gmap.MyLocationEnabled = True
    Else
        Log("No permission!")
    End If
   
    gmap.AddMarker(Lat, Lon, "ALARM: " & deviceID & " " & Volts & "V")
   
    Dim cp As CameraPosition
    cp.Initialize(Lat, Lon, 15)
    gmap.AnimateCamera(cp)
   
End Sub
Note that you can NOT call a sub with 3 or more parameters.

Change the sub to get a list of parameters.

B4X: Copy
Sub LoadMap(parameters As List)
    ' map the list-values to single variables here....
    pnlMap.Visible = True
    Wait For MapFragment1_Ready
    gmap = MapFragment1.GetMap
    rp.CheckAndRequest(rp.PERMISSION_ACCESS_FINE_LOCATION)
    Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
    If Result Then
        gmap.MyLocationEnabled = True
    Else
        Log("No permission!")
    End If
   
    gmap.AddMarker(Lat, Lon, "ALARM: " & deviceID & " " & Volts & "V")
   
    Dim cp As CameraPosition
    cp.Initialize(Lat, Lon, 15)
    gmap.AnimateCamera(cp)
   
End Sub

B4X: Copy
CallSubDelayed2(Main,"LoadMap", Array As Object(par1, par2, par3, par4)).
 
Upvote 0
Back
Top