i have login, register, and home page on my project. I use StartActivity(typeof(Register));
to open register page. When user already insert data and click register button, i use StartActivity(typeof(MainActivity));
to go back to login page again.
When i click back button on my phone it back to register page>login page>then exit. I want my activity that already created is closed after i open a new page.
And my second question, i have exit button, how to close my app using the exit button?
I'm using Visual Studio 2015 and Xamarin for developing android app.
Calling Finish will close and kill the Activity and it will work as expected.
Advertisements. When a user navigates through an Android App, a series of events occurs. For example, when a user launches an app, e.g., the Facebook App, it starts and becomes visible on the foreground to the user, onCreate() → onStart() → onResume().
Calling Finish
will close and kill the Activity
and it will work as expected. Better way to remove an Avtivity
so that it won't appear when Back button is pressed will be to set the NoHistory
of that Activity as true.
If you have a LoginActivity
and a DashboardActivity
and you don't want the LoginActivity
to show while pressing back-button after logging in, you can set NoHistory of LoginActivity
as true, like below.
[Activity (NoHistory = true)]
public class LoginActivity : Activity
{
}
You can use Finish
method to close your current activity:
StartActivity(typeof(MainActivity));
Finish();
To close the app, simply use
System.exit(0);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With