B b4auser1 Well-Known Member Licensed User Longtime User Mar 4, 2015 #1 How to determine the context of current Sub: if the current Sub is called from Service or from Activity ? I need this information to call MsgBox (if Activity) or Log(if Service).
How to determine the context of current Sub: if the current Sub is called from Service or from Activity ? I need this information to call MsgBox (if Activity) or Log(if Service).
eurojam Well-Known Member Licensed User Longtime User Mar 4, 2015 #2 you can add a parameter to the sub like Code: sub HelloWorld (param1 as Parameter, CallingFrom as String) If CallingFrom = "Activity" then MsBox(...) else log(...) end if ... end sub but it is not a real detection....just an idea Upvote 0
you can add a parameter to the sub like Code: sub HelloWorld (param1 as Parameter, CallingFrom as String) If CallingFrom = "Activity" then MsBox(...) else log(...) end if ... end sub but it is not a real detection....just an idea
B b4auser1 Well-Known Member Licensed User Longtime User Mar 4, 2015 #3 Thank you. But passing context as an argument thru many Subs is not very convinient Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Mar 4, 2015 #4 This code will print the full module name of either the service or activity: Code: Public Sub test Dim jo As JavaObject Log(GetType(jo.InitializeContext)) End Sub Are you using many services and activities? Upvote 0
This code will print the full module name of either the service or activity: Code: Public Sub test Dim jo As JavaObject Log(GetType(jo.InitializeContext)) End Sub Are you using many services and activities?
B b4auser1 Well-Known Member Licensed User Longtime User Mar 5, 2015 #5 Erel said: Are you using many services and activities?[/QUOTE I use one Actvity and several services, but many class and code modules with Subs being called from Activity and services. Click to expand... Upvote 0
Erel said: Are you using many services and activities?[/QUOTE I use one Actvity and several services, but many class and code modules with Subs being called from Activity and services. Click to expand...
B b4auser1 Well-Known Member Licensed User Longtime User Mar 5, 2015 #6 Thank you. I tested the code and it resolved my problem, because it returns name of Activity/service even if called from class or code module. Upvote 0
Thank you. I tested the code and it resolved my problem, because it returns name of Activity/service even if called from class or code module.