iOS Question B4A and B4i differences - Menus and Triggering Code Modules

Kevin Hartin

Active Member
Licensed User
I have a B4A project that has numerous Activities, each of which have a single Designer page, most with a Primary panel and a number of sub-panels that get made visible as required. Each page has a menu created with Activity.AddMenuItem and all of the switching between different parts of the App works fine.

I have previously built a Single Page iOS app, but today I ported all of the B4A app to B4i and have been working through all of the differences, to the point that all errors are gone and it is compiling and installing on my iPhone.

However, I am at a total loss when it comes to building a menu system like in B4A with Activity.AddMenuItem. I have created Code Modules equivalent to each B4A Activity Module, but cannot work out how to trigger them like in B4A with StartActivity("ActivityModuleName")

I guess this is a simple question, but I have hit a brick wall on this.
 

Kevin Hartin

Active Member
Licensed User
Thank you Erel, I am now on the right track.

As a rule, is it good practice to put separate app functionality in different activities/module, with their associated pages and panels, or as some posters seem to put all logic in a single activity and load their pages and panels as required?

My current App currently has over 6500 lines of code spread over 10 Activities/Services, including all of the required #if b4a/b4i logic and has 6 somewhat distinct Activities, so through my "Activity.AddMenuItem" menu on each page, I can go directly to the root of any of those activities, closing the current activity with an "Activity.Finish" in the "Activity_Pause" sub on all but the first Activity. Each Panel that gets loaded within an Activity has Save/Close/Cancel buttons that work like a back button.

How can I capture the back button in both B4i and B4A and popup a modal dialog to ask if a Save/Close/Cancel event needs to be performed?

I guess my approach is more like a web developer rather than a pure App developer, but I recognise that step 1 seems to become aware of the differences in approach, so I seem to be slowly getting there. Much compliments on your product, I will be a B4X lifer...
 
Upvote 0

Kevin Hartin

Active Member
Licensed User
Should I also be using the ActivityClass as per ActivityClass: A cross-platform development class and strategy for b4i/b4a ?

I implemented this throughout my project yesterday and I think I have got myself into a bit of a twist.

Also, can you confirm that if I link the Starter Service from my B4A project as a Module called Service in the B4i project, it will run before Main. This seems to be the case, but I cannot find any documentation to that effect.

Thanks,
Kev
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
As a rule, is it good practice to put separate app functionality in different activities/module, with their associated pages and panels, or as some posters seem to put all logic in a single activity and load their pages and panels as required?
I would say that it is recommended to split the code into more manageable components. It doesn't mean that you need to use multiple activities. You can have a single activity and many classes.

How can I capture the back button in both B4i and B4A and popup a modal dialog to ask if a Save/Close/Cancel event needs to be performed?
There is no back button in iOS.

I'm not familiar enough with this solution.

Also, can you confirm that if I link the Starter Service from my B4A project as a Module called Service in the B4i project, it will run before Main. This seems to be the case, but I cannot find any documentation to that effect.
The Starter module will be a regular module in B4i. You can call it from Application_Start:
B4X:
Private Sub Application_Start (Nav As NavigationController)
 Starter.Service_Create
 Starter.Service_Start(Null)
 
Upvote 0
Top