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:
CallSubDelayed(Main,"LoadMap").
I receive the following error:
code:
java.lang.Exception: Sub loadmap signature does not match expected signature.
What is the correct syntax?
 

DonManfred

Expert
Licensed User
Longtime User
B4X:
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:
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:
CallSubDelayed2(Main,"LoadMap", Array As Object(par1, par2, par3, par4)).
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…