Hello,
Following @Informatix's advice, here is a simple way I was not aware of to pass a reference of a view to a service.
As you already know, Views can only be declared in Globals. So I use a Globals list as a gateway to a wider Process_Globals list that can be retrieved from the service. Like this :
In the Activity
And in the service where I need the reference to the view :
I hope this could help someone who didn't got it (like me) previously
Following @Informatix's advice, here is a simple way I was not aware of to pass a reference of a view to a service.
As you already know, Views can only be declared in Globals. So I use a Globals list as a gateway to a wider Process_Globals list that can be retrieved from the service. Like this :
In the Activity
B4X:
Sub Process_Globals
'this list is used as a way to pass the View as a Process_Global
Dim L1 As List
End Sub
Sub Globals
'this list is used as a gateway between Globals and Process_Globals
Dim L As List
Dim mView As Label 'or any other view I think
End Sub
Sub Activity_Create(FirstTime As Boolean)
If Not(L.IsInitialized) Then L.Initialize
If Not(L1.IsInitialized) Then L1.Initialize
If FirstTime Then
mView.Initialize("")
mView.Text= "Some text"
L.Add(mView) 'stores the view in the gateway
L1.Add(L.Get(0)) 'stores the view from the gateway to the system wide
End If
End Sub
And in the service where I need the reference to the view :
B4X:
Sub RemoveOverlay
Dim mView As Label 'same type as the view to retrieve
mView.Initialize("")
mView=Main.L1.Get(0) 'gets the reference to the view
End Sub
I hope this could help someone who didn't got it (like me) previously