예제 #1
0
 /// <summary>
 /// 后台运行设置
 /// </summary>
 public void BackgroundOperationSetting()
 {
     if (IsHuawei())
     {
         GoHuaweiSetting();
     }
     else if (IsXiaomi())
     {
         GoXiaomiSetting();
     }
     else if (IsOPPO())
     {
         GoOPPOSetting();
     }
     else if (IsVIVO())
     {
         GoVIVOSetting();
     }
     else if (IsMeizu())
     {
         GoMeizuSetting();
     }
     else if (IsSamsung())
     {
         GoSamsungSetting();
     }
     else
     {
         ToastUtils.ShowSingleToast("没有检测到机型!");
     }
 }
예제 #2
0
        public override bool OnKeyDown([GeneratedEnum] Keycode keyCode, KeyEvent e)
        {
            if (keyCode == Keycode.Back && e.Action == KeyEventActions.Down)
            {
                //这里解决Popup 弹出后,点击回退健时不能释放Popup问题
                Device.BeginInvokeOnMainThread(async() =>
                {
                    if (PopupNavigation.Instance.PopupStack.Count > 0)
                    {
                        await PopupNavigation.Instance.PopAllAsync();
                    }
                });

                if (!lastBackKeyDownTime.HasValue || (DateTime.Now - lastBackKeyDownTime.Value) > new TimeSpan(0, 0, 2))
                {
                    var actionPage = App.Current.MainPage;
                    if (actionPage?.Navigation != null && actionPage?.Navigation?.NavigationStack?.Count != 0)
                    {
                        actionPage = actionPage.Navigation.NavigationStack.Last();
                        if (null != actionPage)
                        {
                            if (actionPage is MainLayoutPage)
                            {
                                ToastUtils.ShowSingleToast("再按一次退出程序");

                                lastBackKeyDownTime = DateTime.Now;
                                return(true);
                            }
                            else if (actionPage is LoginPage)
                            {
                                MoveTaskToBack(true);
                                return(false);
                            }
                            else
                            {
                                Device.BeginInvokeOnMainThread(async() =>
                                {
                                    await actionPage?.Navigation.PopAsync(true);
                                });
                            }
                        }
                    }
                }
                else
                {
                    //移除Activity
                    AppManager.Instance().ExitApp();
                }
                return(true);
            }
            return(base.OnKeyDown(keyCode, e));
        }