B4J Tutorial In-line Java in multiple modules

Daestrum

Well-Known Member
Licensed User
I have been using the in-line java for ages and only just discovered that you do not have to put all the code in one module, as I was previously doing.
It can be placed in the module to which it relates to.
'Me' only refers to the current module.
B4X:
Sub inline As JavaObject
     return Me ' the Me of this module
End Sub
...
 Log(inline.RunMethod("xxx",Null))
...
Running the above for example in Main, would only access the in-line java code inserted into the Main module.
Each module (either class or code) can have its own inline, that will only run the code in that module.

Providing each module has an 'inline' sub, you can also run the code from any other module.

eg,
Suppose project has two modules Main and module2 and both have in-line java and inline sub.

To run the java code in Main from Main module use: inline.RunMethod("xxx",array(yyy))
To run the java code in module2 from Main module use: module2.inline.RunMethod("aaa",array(bbb))

This way the in-line java code relating to each module stays with the module, making it easier to maintain.

Attached is an example with Main module, Code module and Class module.
 

Attachments

Top