Activity still added to the stack after Activity.Finish

tamadon

Active Member
Licensed User
Longtime User
I call an activity (say Activity A) from the main activity. In Activity A, I initialize some objects from a class. The object is referenced on the Process Globals of Activity A so that I can access the object from other Activity.

I click the Next button to exit Activity A and call Activity.Finish to remove it from the Activity stack. Then move to another activity(say B).

Activity B will refer the objects initialized from Activity A.

However when I click on the back button while on Activity B, Activity A is still being displayed even though I have called Activity.Finish. I thought I should go straight to the main activity?

Main <-> Activity A (Activity.Finish called when exiting) <-> Activity B

Does referring the objects from Activity A recreate the activity?
 

mc73

Well-Known Member
Licensed User
Longtime User
I don't know what's causing this, but you can always trap the 'back' button and send your app to the activity you choose.
 
Upvote 0

Kevin

Well-Known Member
Licensed User
Longtime User
Are you using CallSubDelayed to call subs in activity A? I think that could possibly cause that behavior but I would guess that activity A would reappear before closing activity B. Just an idea to run by you while troubleshooting the problem.
 
Upvote 0

tamadon

Active Member
Licensed User
Longtime User
I don't know what's causing this, but you can always trap the 'back' button and send your app to the activity you choose.

I've done that actually but it ignores the instruction and still display Activity A

So in Activity B I have this but it doesn't work.

B4X:
Sub Activity_KeyPress (KeyCode As Int) As Boolean 'Return True to consume the event
   If KeyCode = KeyCodes.KEYCODE_BACK Then      
      Activity.Finish
      SPClock.Pause(SPPClock)
      StartActivity(Main)
      storyClass.SetAnimation("zoom_enter", "zoom_exit")
      Return True
   End If
End Sub
 
Upvote 0

tamadon

Active Member
Licensed User
Longtime User
Are you using CallSubDelayed to call subs in activity A? I think that could possibly cause that behavior but I would guess that activity A would reappear before closing activity B. Just an idea to run by you while troubleshooting the problem.

Was thinking of doing that initially but I decided to refer the objects via Activity A's Process_Globals instead to avoid re-creating Activity A
 
Upvote 0

tamadon

Active Member
Licensed User
Longtime User
Ahh.. I should have checked the log closer. I appears that it does go straight to the main activity... but there's a flag in the Activity Resume that mistakenly calls Activity A again :sign0161:

Anyway thanks everyone for the response :)
 
Upvote 0
Top