activity.finish does not close my app

ilan

Expert
Licensed User
Longtime User
hi

i am trying to close my app via activity.finish
but all it does is to to close the main activity and change to another activity but my app is still running

what am i doing wrong?

thanx
 
Last edited:

ilan

Expert
Licensed User
Longtime User
but i am closing the main activity, do i have to close all activities before i close the main? then my app will exit?

thanx
 
Upvote 0

spillo3d96

Member
Licensed User
Longtime User
suggest that when you change the current Activity you should use the code below:
B4X:
StartActivity(secondActivity)
Activity.finish

Yes, that is correct if you want ,when you start second activity, the main activity will close.
But if i understand correctly, you wanted to close completely the app...
So you can use:
B4X:
Exit.Application
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
You need to define how you want or need to navigate between your activities.
Let's take some examples.
We have three activities Main, Page1, Page2 and we go back with the back button.
The navigations below work without any Activity.Finish.
1) Main > Page1 (Back) > Main > Page2 (Back) > Main (Back) > Exit
2) Main > Page1 > Page2 (Back) > Page1 (Back) > Main (Back) > Exit
In example 2) if you had an Activity.Finish in Page2 you would't go back to Page1 but directly to Main.

If you want a navigation like this:
3) Main > Page1 > Page2 (Back) > Main (Back) > Exit
Here you need an Activity.Finish in Page1

There is no general rule you must define how you want to navigate and according to this you should add Activity.Finish or not.

Best regards.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…