Android Question Is there an "include file" directive or better solution?

scGuy

Member
Licensed User
Perhaps I don't understand how to organize a cross platform project. For example, I create a new B4XPages Project in B4A. I place API keys etc in Main -> Process_Globals for obfuscation. The real work gets done in B4XMainPage.

Now I close the project and open it in B4J. B4XMainPage is still there. But Main -> Process_Globals does not contain my API keys and other obfuscated variables. Because in B4A this is in the file MyProject.b4a, and when opening from B4J the project file is MyProject.b4j

Is there some kind of #include directive where I could create an APIKeys.txt file or something and then include it in both B4A and B4J inside process globals?
 

William Lancee

Well-Known Member
Licensed User
Longtime User
In B4XPages, 'Main' is where almost all platform differences are magically compensated for. Therefore there are 3 completely different 'Main' s.
When you open the project and go to each platform, the 'Main' part is different.

That means that all the common work must be done in instances of B4XPages classes.
The first and only instance of B4XMainPage (instance is 'B4Xpages.MainPage') is the common entry point to the project.

Here you can set constants in 'Sub Class_Globals' or read parameter files. If you declare a variable XXX as Public in the Class_Globals of
B4XMainPage., you can access it any with B4Xpages.MainPage.XXX from anywhere in your project.

[Warning: obfuscation (your own or the built-in method of the IDE) does not protect against persistent hackers]
 
Upvote 0
Top