Пример #1
0
        public void GoToMain()
        {
            Intent intent = new Intent(activity, typeof(MainActivity));

            ActivityCompat.FinishAffinity(activity);
            activity.StartActivity(intent);
        }
Пример #2
0
        public void RestarApp()
        {
            Intent intent = new Intent(activity, typeof(SplashActivity));

            ActivityCompat.FinishAffinity(activity);
            activity.StartActivity(intent);
        }
Пример #3
0
        private void SetBackAlert()
        {
            try
            {
                //set alert for executing the task
                if (alert == null)
                {
                    alert = new Android.Support.V7.App.AlertDialog.Builder(this);
                }

                alert.SetMessage("Are you sure you want to exit?");
                alert.SetCancelable(false);

                alert.SetPositiveButton("Exit", (senderAlert, args) =>
                {
                    ActivityCompat.FinishAffinity(this);
                });

                alert.SetNegativeButton("Cancel", (senderAlert, args) =>
                {
                    //perform your own task for this conditional button click
                });
                //run the alert in UI thread to display in the screen
                RunOnUiThread(() =>
                {
                    alert.Show();
                });
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Пример #4
0
        public void LogoutExpired()
        {
            var    activity = Locator.Current.GetService <Activity>();
            Intent intent   = new Intent(activity, typeof(LoginActivity));

            ActivityCompat.FinishAffinity(activity);
            activity.StartActivity(intent);
        }
Пример #5
0
        public virtual bool OnSupportNavigateUp()
        {
            var parent = this.SupportParentActivityIntent;

            if (parent != null)
            {
                if (this.SupportShouldUpRecreateTask(parent))
                {
                    var taskStackBuilder = TaskStackBuilder.Create(this);
                    this.OnCreateSupportNavigateUpTaskStack(taskStackBuilder);
                    this.OnPrepareSupportNavigateUpTaskStack(taskStackBuilder);
                    taskStackBuilder.StartActivities();

                    try
                    {
                        ActivityCompat.FinishAffinity(this);
                    }
                    catch (IllegalStateException)
                    {
                        // This can only happen on 4.1+, when we don't have a parent or a result set.
                        // In that case we should just finish().
                        this.Finish();
                    }
                }
                else
                {
                    // This activity is part of the application's task, so simply
                    // navigate up to the hierarchical parent activity.
                    this.SupportNavigateUpTo(parent);
                }

                return(true);
            }

            return(false);
        }