Android Question Back Button - Activity Pauses and Resumes Repeatedly

Nostrildumbass

Member
Licensed User
Longtime User
I've been plagued with this problem ever since I started working with B4A. I've just let it slide for so long but I'd like to figure out what is wrong and how to fix it.

I have about 10 activities in total. Let's say I "hop" from activities 1-4 as such:
1: My main/login screen
2. A "mode" selection screen (there are 2 modes to choose from)
3. An activity for the selected mode (a different activity according to which mode was chosen)
4. A "chat" activity that loads different data according to what was selected in activity 3.

If I hit the back key quickly as activity 4 is popping into view, activity 4 exits and I am taken back to activity 3 as expected, however activity 4 "pops" back into view, then back out to 3. Sometimes it repeatedly does this a few times, and sometimes it'll just sit there indefinitely switching between activity 3 and 4. My pause event for activity 4 is nothing but switching a boolean to false, and its resume just initializes a timer and switches that boolean to true.

It doesn't happen very often if I let activity 4 load entirely and then hit back; it happens more frequently if I tap the back key just as activity 4 is coming into view. I've tried inserting DoEvents into both activity's resume/pause events in all combinations I can think of but can't get this to stop behaving this way.
 

LucaMs

Expert
Licensed User
Longtime User
Since I'm not very smart, for me it is not easy to understand just by reading, especially in English.

My advice is to create an "empty" app (containing simple layouts) and test / post it.

As you talk about Timer, probably you must disable it.
 
Upvote 0

Nostrildumbass

Member
Licensed User
Longtime User
Since I'm not very smart, for me it is not easy to understand just by reading, especially in English.

My advice is to create an "empty" app (containing simple layouts) and test / post it.

As you talk about Timer, probably you must disable it.

I figured it is something I'll have to replicate in a blank sample project.

I've tried disabling my timer as well as a few other things that activity handles. My next step will be to just comment out everything in the activity and see if it still behaves that way. If so I can maybe upload a video of the behavior then, too.
 
Upvote 0
Top