Skip to content

Instantly share code, notes, and snippets.

@jeevan-vj
Created March 15, 2018 13:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeevan-vj/040ddc50b82b12c6f4c7fc126cb2471d to your computer and use it in GitHub Desktop.
Save jeevan-vj/040ddc50b82b12c6f4c7fc126cb2471d to your computer and use it in GitHub Desktop.
Double tap to exit xamarin android
private bool doubleBackToExitPressedOnce = false;
public override void OnBackPressed()
{
if (doubleBackToExitPressedOnce)
{
base.OnBackPressed();
Java.Lang.JavaSystem.Exit(0);
return;
}
this.doubleBackToExitPressedOnce = true;
Toast.MakeText(this, "Double tap to exit", ToastLength.Short).Show();
new Handler().PostDelayed(() =>
{
doubleBackToExitPressedOnce = false;
}, 2000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment