As
@Erel suggested, B4XPages would be simpler, but to answer your question each "activity" is basically it's own "program." If you call "Activity2.Subroutine1(SomeParm)" the activity you're in stops running and the activity you called starts running.
To use this methodology, you will need to store the necessary global variables in the Starter service or in a module and then access them from each activity via "Starter.MyVariable1" or "ModuleName.MyVariable1."