Android Question "Main" name clarification please?

jccraig

Member
Licensed User
Longtime User
Just getting up to speed with B4A. I created a simple example with one activity and layout, and gave them my own name when asked to do so during the first save. Later I recalled reading that the primary activity and its layout should always be named "Main". Can you clarify? Why am I asked for a name if it must be Main, and what happens if I do use some other name for either the activity or its layout?
 

JonPM

Well-Known Member
Licensed User
Longtime User
The first activity is always Main, thus needs to be named this. Your layout (created in the designer) does NOT have to be called main. It can be called whatever you want.
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
Main is the name of the always there first module.
If you create a single "screen" app (single activity), then your app will only have the StarterService and Main.
If you add another activity or class or code module, you can name them whatever fits your logic.
Layouts can have whichever name you like and be used in whichever activity you want, you can even reuse the same layout in two different activities.
 
Upvote 0

jccraig

Member
Licensed User
Longtime User
I'm still confused a bit. Within my project's files I see the Starter.bas file, and I see Act2.bas for an added activity, but I don't see Main.bas file as expected. I do see a .bas file with the name of my project. Is that where the Main activity is stored? If so, it feels like there are two names used for the same Main activity code. To force more clarity and consistency, I'd like to save my project in a folder that has my project's name, but when I do the very first Save, I'd like to name it Main. Then the file names would match their activity names in all cases, and the project would be defined and named by the folder it's all contained within. Is there any reason I should not do this? Am I overlooking something?
 
Upvote 0

JonPM

Well-Known Member
Licensed User
Longtime User
Correct, Main is located in the main project file (.b4a). You can name this file whatever you'd like, including main.b4a. I would assume the reason not to have a separate main.bas file is because one might think it would be ok to delete it. On the contrary, you do not need to have starter.bas.

One reason I can think of not to name your project main.b4a is that it might be difficult to discern between numerous projects when using the File > Open Recent dialog (either in B4A itself, or the Windows one).
 
Upvote 0
Top