Android Question Advice of How to choose between one service or another

Alberto Michelis

Well-Known Member
Licensed User
Longtime User
Hi, in my app have two services, sometime I need server 1 to be running and som the service 2.

Im using the following code in a "Code Module", it is ok to do it this way?

Main.Versionnivel selects the service to run

B4X:
Sub ChooseReadingService
    Log(">>>> choose server version=" &Main.VersionNivel)
    If Main.VersionNivel<>0 Then
        If ServicioCorriendo<>"PortIt" Then
            ServicioCorriendo="PortIt"
            Log("---- tuns on service PortIt ---")
            StopService(LeeWebRava)
            StopService(LeeWeb)
            StartService(LeeWeb)
            CallSub(LeeWeb,"Timer1_Tick")
        Else
            Log("---- still running service PortIt ---")
        End If   
    Else   
        If ServicioCorriendo<>"RavaDelayed" Then
            ServicioCorriendo="RavaDelayed"
            Log("---- turns on service Rava ---")
            StopService(LeeWeb)
            StopService(LeeWebRava)
            StartService(LeeWebRava)
            CallSub(LeeWebRava,"Timer1_Tick")
        Else
            Log("---- still running service Rava ---")
        End If   
    End If   
End Sub

Thanks
 
Top