Esempio n. 1
0
        protected override bool OnBackButtonPressed()
        {
            INativeHelper nativeHelper = null;

            nativeHelper = DependencyService.Get <INativeHelper>();
            if (nativeHelper != null)
            {
                nativeHelper.CloseApp();
            }
            nativeHelper.CloseApp();
            base.OnBackButtonPressed();
            // Always return true because this method is not asynchronous.
            // We must handle the action ourselves: see above.
            return(true);
        }
        protected override bool OnBackButtonPressed()
        {
            try
            {
                // Begin an asyncronous task on the UI thread because we intend to ask the users permission.
                Device.BeginInvokeOnMainThread(async() =>
                {
                    if (await DisplayAlert("Exit page?", "Are you sure you want to exit this page? You will not be able to continue it.", "Yes", "No"))
                    {
                        INativeHelper nativeHelper = null;
                        nativeHelper = DependencyService.Get <INativeHelper>();
                        if (nativeHelper != null)
                        {
                            nativeHelper.CloseApp();
                        }
                        base.OnBackButtonPressed();

                        //await Navigation.PopAsync();
                    }
                });
            }
            catch (Exception ex)
            {
                Logging.Write(ex, "OnBackButtonPressed");
            }
            // Always return true because this method is not asynchronous.
            // We must handle the action ourselves: see above.
            return(true);
        }