Android Question calling subs from other activities

apti

Member
I have a case that I bring up a screen or activity on top of another. The form is basically modal. I need to take information from the 2nd screen and put it into the 1st screen and click a button.

I have not figured out how to do this simple thing. Can I get help?
 

Filippo

Expert
Licensed User
Longtime User
I have a case that I bring up a screen or activity on top of another. The form is basically modal. I need to take information from the 2nd screen and put it into the 1st screen and click a button.

I have not figured out how to do this simple thing. Can I get help?
Define a variable for the information in the starter service or in a code module, so you can change and check the variable from any activity.
 
Upvote 0

Jeffrey Cameron

Well-Known Member
Licensed User
Longtime User
I have a case that I bring up a screen or activity on top of another. The form is basically modal. I need to take information from the 2nd screen and put it into the 1st screen and click a button.

I have not figured out how to do this simple thing. Can I get help?
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."
 
Upvote 0

apti

Member
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."
a switch to b4x is not going to help here. means rewriting. The problem is as you described. I am doing this
Page 1 is the normal page that does everything.
page 2 is a front end that optionally can be used to send information often as a macro to page1

All the processing is done on page1 but if page1 is suspended while page2 runs how can I get something on page1 to run without stopping page2?
 
Upvote 0

Jeffrey Cameron

Well-Known Member
Licensed User
Longtime User
a switch to b4x is not going to help here. means rewriting. The problem is as you described. I am doing this
Page 1 is the normal page that does everything.
page 2 is a front end that optionally can be used to send information often as a macro to page1

All the processing is done on page1 but if page1 is suspended while page2 runs how can I get something on page1 to run without stopping page2?
Short answer, it can't. That's why @Erel suggested you use B4xPages instead of multiple activities.

 
Upvote 0

Sagenut

Expert
Licensed User
Longtime User
a switch to b4x is not going to help here. means rewriting. The problem is as you described. I am doing this
Page 1 is the normal page that does everything.
page 2 is a front end that optionally can be used to send information often as a macro to page1

All the processing is done on page1 but if page1 is suspended while page2 runs how can I get something on page1 to run without stopping page2?
If you don't want to switch to B4XPages than you could show in a Panel what you are now showing in the second Activity, keeping all the code in a single activity.
Anyway I think that switching to Pages would not require so much rewriting.
 
Upvote 0

apti

Member
If you don't want to switch to B4XPages than you could show in a Panel what you are now showing in the second Activity, keeping all the code in a single activity.
Anyway I think that switching to Pages would not require so much rewriting.
is there another advantage to pages? and what is so different?

as for the issue I found a work around. I finish the activity allow the main process to continue and process then restart the 2nd activity and return where you left off.
 
Upvote 0

josejad

Expert
Licensed User
Longtime User
I have a case that I bring up a screen or activity on top of another.
Understand this example (maybe harder than switching to B4XPages)


put it into the 1st screen and click a button.

 
Upvote 0
Top