Android Question Activity or Service

b4auser1

Well-Known Member
Licensed User
Longtime User
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
you can add a parameter to the sub like
B4X:
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

b4auser1

Well-Known Member
Licensed User
Longtime User
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
Top