Class Module and StartActivity

airblaster

Active Member
Licensed User
Longtime User
I have a class module that starts another activity.
However, the class modules program execution doesn't pause after starting the activity.
Is there any way to make the class module wait for the activity to finish?
 

airblaster

Active Member
Licensed User
Longtime User
StartActivity wasn't the last command in the class, I needed some checks after it.
I know the class keeps running because I went through the process flow with the debugger, step by step.
 
Upvote 0

margret

Well-Known Member
Licensed User
Longtime User
Why don't you call a sub in the calling Activity and that sub will start the second activity. That way the control should be returned to the calling/main activity.

'In the class have something like:
B4X:
If MyConition Then
      CallSub2(Main, "yoursubname", parameters_if_needed)
End Sub

'In the Main or Calling Activity to the Class
B4X:
Sub yoursubname
      'Start your second Activity
End Sub
 
Last edited:
Upvote 0

airblaster

Active Member
Licensed User
Longtime User
Actually I want to do the opposite:
Calling a Sub in a Class Module that calls an Activity, while the main activity is supposed to wait for the result.
 
Upvote 0

margret

Well-Known Member
Licensed User
Longtime User
I know and understood that. What I was showing is when your Activity calls the sub in the class, when that sub is finished and it has checked the condition and it tests out to call the second Activity, have it then to call a sub in the main calling Activity, which in turn calls the second Activity.

If your class is declared in process_globals, it should still be running. If not, it is the checks after the call to start the second Activity that is keeping it running, You should compllete all of your checks before you start the new Activity.

I would assume that the class code like a code mode is all ways loaded in memory.
 
Upvote 0

airblaster

Active Member
Licensed User
Longtime User
I think I get the idea now, thanks for the suggestion.
But I guess it wouldn't work for my use case.

Maybe I should elaborate on what I'm planning to do:
The App needs an internet connection at many times, so before requesting an internet resource I check if a connection is available. If there is no connection, the user is forwarded to a connection error activity.
Once the user established a connection, he'll be returned to the calling activity.
For this process to work, I need the calling activity to be paused until the user returns from the connection error activity.
 
Upvote 0
Top