Android Question Close current activity after starting a new one

nibbo

Active Member
Licensed User
Longtime User
Hi all
I have an app that needs to close after it starts a new activity.
It is possible that I have not really structures the activities very well but that's a lesson for another time.
Currently the first 'Main' activity displays a login screen.
Once the login has been validated I want to start a new activity and kill the current one.

I have tried:
B4X:
StartActivity(Dashboard)
Activity.Finish
But when I do an ExitApplication in the Dashboard activity it closes DashBoard but the Main is still there!

Is there a better way to achieve this?

Thanks
 

LucaMs

Expert
Licensed User
Longtime User
Close the Main activity would close the app.

You could use a panel superimposed on the Main, in which to enter data for the login and set pnlLogin.Visible = False if login is ok.

So I mean that you could use a single activity (Dashboard could be the main activity)
 
Upvote 0

nibbo

Active Member
Licensed User
Longtime User
Hi Erel; Sorry I actually tried ExitApplication which did not work so I did change it to Activity.Finish but this still left the first activity running even though I had issued an Activity.Finish in the first app.
 
Upvote 0

nibbo

Active Member
Licensed User
Longtime User
Close the Main activity would close the app.

You could use a panel superimposed on the Main, in which to enter data for the login and set pnlLogin.Visible = False if login is ok.

So I mean that you could use a single activity (Dashboard could be the main activity)

Hi Luca, thanks for the response.
By the time this particular app is finished there will be three or four different activities so I don't really want to superimpose each one on top of the main activity ass the code would become terribly unwieldy and none of it reusable.
I do need a reliable way of starting / ending activities at will.
Thanks for taking the time to reply.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Hi Erel; Sorry I actually tried ExitApplication which did not work so I did change it to Activity.Finish but this still left the first activity running even though I had issued an Activity.Finish in the first app.
Calling Activity.Finish should close the current activity. Try to reproduce it in a new project to test it.
 
Upvote 0
Top