Android Question How can I pass a Sub as parameter

tonyp

Member
Licensed User
Longtime User
Hi,

Now that we can have shared code libraries I thought about writing some generic code that calls the method passed in as parameter.

For example, I want to pass Activity.Finish to a Sub to have it called under specific conditions.

Is this possible somehow?

TIA
 

LucaMs

Expert
Licensed User
Longtime User
For your example, you can pass the Activity as a parameter, not the "sub" Finish.

YourModule
B4X:
public sub EndActivity (Act as actvity)
  Act.Finish
end sub


But, even if I have not shared modules , they should be used to take advantage of their routine, not vice versa.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
But Activity.Finish shows as undeclared in that shared code module!
You should have explained more details of the situation.
WE dont know that it is a code-module. So we are thinking about the same activity..
We dont get infos about any error you got.
 
Upvote 0

tonyp

Member
Licensed User
Longtime User
@DonManfred Well, I did start by saying "... we can have shared code libraries ..." so it is assumed I'm referring to a problem in relation to that, or else that sentence would be irrelevant noise. Agreed about not mentioning the actual error, though. Thanks.

@LucaMs Thanks, this worked.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…