Android Question Problem with remaining activities ....

Yayou49

Active Member
Licensed User
Hi,

Let me explain my problem:

I have 4 activities. A1, A2, A3, A4.
A1 call A2 with a startactivy(A2)
A2 call A3 with a startactivy(A3)
A3 call A4 with a startactivy(A4)

When job of A4 is done, it comes back to A2 with a startactivy(A2) (or a callsubdelay2.....)

When on A2, if I click on back button, A3 and A4 appear again.

I've tried tu put an activity.finish before or after the startactivity, but it does nothing or worse I can't go further.

So, how can I, successfully and definitively, close an activity and where ??

Thx in advance.
 

ronell

Well-Known Member
Licensed User
Longtime User
When on A2, if I click on back button, A3 and A4 appear again.
default behavior of back button is activity.finish.. i guess so thats why A3 and A4 appears ..
you can try to intercept the back button using
B4X:
Sub activity_KeyPress (KeyCode As Int) As Boolean

    If KeyCode = KeyCodes.KEYCODE_BACK Then
 
Upvote 0

MaFu

Well-Known Member
Licensed User
Longtime User
Hi,

Let me explain my problem:

I have 4 activities. A1, A2, A3, A4.
A1 call A2 with a startactivy(A2)
A2 call A3 with a startactivy(A3)
A3 call A4 with a startactivy(A4)

When job of A4 is done, it comes back to A2 with a startactivy(A2) (or a callsubdelay2.....)

When on A2, if I click on back button, A3 and A4 appear again.

I've tried tu put an activity.finish before or after the startactivity, but it does nothing or worse I can't go further.

So, how can I, successfully and definitively, close an activity and where ??

Thx in advance.

Try this:
When A3 calls A4 also call activity.finish.
When job of A4 is done call activity.finish instead of startactivity(A2).
 
Upvote 0

Yayou49

Active Member
Licensed User
Try this:
When A3 calls A4 also call activity.finish.
When job of A4 is done call activity.finish instead of startactivity(A2).

I've tried this solution, but with an activity.finish, my startactivity doesn't work (even if I put activity.finish after the startactivity).
System finish the activity and go back to the previous one.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
The attached test program does what you want.
On Act1, Act2 and Act3 there is a button to go to the next activity.
Pressing Back on Act4 jumps to Ac2.

Act1 > Next > Act2 StartActivity(Act2)
Act2 > Next > Act3 StartActivity(Act3)
Act3 > Next > Act4 Activity.Finish / StartActivity(Act3)
Act4 > Back > Act2
 

Attachments

  • Test4Activities.zip
    10.8 KB · Views: 233
Upvote 0
Top