Reputation: 41
I'm new to Android. My problem is:
Activity A has a loop. Somewhere in the middle of loop, Activity B is called, and once B finishes, A should resume the loop from where it left off.
I tried to code this, but what happens right now is that Activity A calls B, but B is not entered, then A resumes the loop and again calls B.
Essentially, the calls to B are stacked and once the loop in A completes, one by one the calls to B in stack are executed, so finally the first call to B is executed last in a last-in first-out order. I just want to execute B once, at the appropriate time.
Can anyone help me?
Upvotes: 0
Views: 1102
Reputation: 3447
Take a look at Starting Activity for result. You can start Activity B for some result, and when Activity B finishes, the onActivityResult
method of Activity A will be called and you can set it to continue/start work there.
EDIT
Based on your updated question you can try:
Upvotes: 0
Reputation: 5815
You are using the wrong design paradigm for your app. You should not start another activity like that. Keep the code on separate modules by all means, but do not start another activity just to transfer control.
Upvotes: 1
Reputation: 1996
Your activity will resume, when calling the Acticity B, don't finish Activity A. If you need to write some code when it resumes. you can do that by overriding onResume method of Activity A.
Upvotes: 0