Android Question Tell if Object is Activity or Service

Erel

B4X founder
Staff member
Licensed User
Longtime User
Add to Starter service:
B4X:
Sub Process_Globals
   Public Modules As Map
End Sub

Sub Service_Create
   Modules.Initialize
   Modules.Put(Me, True)
End Sub

Add to all activities:
B4X:
Sub Activity_Create(FirstTime As Boolean)
   Starter.Modules.Put(Me, False)

Now you can check with:
B4X:
If Starter.Modules.GetDefault(SomeObject, "Error") = True Then
 Log("service")
Else
Log("activity")
End If
 
Upvote 0
Top