Reputation: 123
How can we check application is going to be exit in OnBackButtonPressed()
protected override bool OnBackButtonPressed()
{
//Exit form application?
base.OnBackButtonPressed();
return false;
}
Upvotes: 0
Views: 594
Reputation: 123
protected override bool OnBackButtonPressed()
{
Device.BeginInvokeOnMainThread(async () =>
{
if (await DisplayAlert("", "Exit the application?", "Yes", "No"))
{
if (Device.RuntimePlatform == Device.Android)
{
Android.OS.Process.KillProcess(Android.OS.Process.MyPid());
}
else if (Device.RuntimePlatform == Device.iOS)
{
Thread.CurrentThread.Abort();
}
}
});
return true;
}
Upvotes: 2