Hello, I Am trying to get a user confirmation box when user clicks back button from my app for asking him whether he wants to exit or not and with selection of Yes, App should exit. I am using code mentions bellow but it is not working properly as with the selection of Yes for exiting the App, App does not exit and if I click back button once again then it exits. Can anyone help me with this
public bool CloseApp = true;
protected override bool OnBackButtonPressed()
{
Device.BeginInvokeOnMainThread(async () =>
{
var result = await this.DisplayAlert("Attention!", "Do you really want to exit the application?", "Yes", "No");
if (result)
{
CloseApp = false;
}
});
return CloseApp;
}