Doble Tab to Exit in Microsoft MAUI

Bhuwan 616 Reputation points
2022-09-03T03:18:53.95+00:00

HI,
How to integrate Double tab to exist in MAUI same as Xamarin forms. can anyone suggested me or share me some stuff.

Thanks

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
2,923 questions
{count} votes

Accepted answer
  1. Leon Lu (Shanghai Wicresoft Co,.Ltd.) 68,741 Reputation points Microsoft Vendor
    2022-09-05T06:46:11.253+00:00

    Hello,

    You can invoke platform code in MAUI directly. No need to use dependenceService.

    I use following code

       try  
               {  
                   if (BackPressCounter == 2)  
                   {  
                       // DependencyService.Get<IAndroidMethods>().CloseApp();  
       #if ANDROID  
                       Android.OS.Process.KillProcess(Android.OS.Process.MyPid());  
       #elif IOS  
                         //add your ios platform code to close application  
       #else  
                         //add your code  
       #endif  
         
                   }  
                   else if (Navigation.NavigationStack.Count == 1)  
                   {  
                       BackPressCounter++;  
                       //DependencyService.Get<BackPressMessage>().Show("Double tap to exit");  
         
       #if ANDROID  
                       Android.Widget.Toast.MakeText(Android.App.Application.Context, "Double tap to exit", Android.Widget.ToastLength.Long).Show();  
       #elif IOS  
                         //add your ios platform code to close application  
       #else  
                         //add your code  
       #endif  
                   }  
                   else  
                   {  
                       Navigation.PopAsync();  
                   }  
               }  
               catch (Exception ex)  
               {  
         
               }  
    

    Best Regards,

    Leon Lu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful