So I had to implement double tap to exit from app in Android using xamarin. This how it is implemented
- Create blank Android App

- Override OnBackPressed method in MainActivity.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | |
| } |
- That’s it 🙂 Run the app and see the out put


Thanks. 🙂