Example #1
0
        public override void ExitApplication()
        {
#pragma warning disable 618
            JavaSystem.RunFinalizersOnExit(true);
#pragma warning restore 618
            JavaSystem.Exit(0);
        }
Example #2
0
        /**
         * 当UncaughtException发生时会转入该函数来处理
         */
        public void UncaughtException(Thread thread, Throwable ex)
        {
            if (!handleException(ex) && mDefaultHandler != null)
            {
                //如果用户没有处理则让系统默认的异常处理器来处理
                mDefaultHandler.UncaughtException(thread, ex);
            }
            else
            {
                DownloadBookService.cancel(); // 取消任务
                LogUtils.i("取消下载任务");
                new Thread(() => {
                    Looper.Prepare();
                    ToastUtils.showSingleToast("哎呀,程序发生异常啦...");
                    Looper.Loop();
                }).Start();

                try {
                    Thread.Sleep(3000);
                } catch (InterruptedException e) {
                    LogUtils.e("CrashHandler.InterruptedException--->" + e.ToString());
                }
                //退出程序
                Process.KillProcess(Process.MyPid());
                JavaSystem.Exit(1);
            }
        }
Example #3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState, Resource.Layout.frmLogout);

            translateScreen();

            clearTextOnClick(FindViewById <ImageButton>(Resource.Id.imClear), FindViewById <EditText>(Resource.Id.tfPassPrompt));
            FindViewById <Button>(Resource.Id.btnLogout).Click += (sender, e) =>
            {
                var password = FindViewById <EditText>(Resource.Id.tfPassPrompt).Text;
                if (password == Configuration.logoutPassword)
                {
                    JavaSystem.Exit(0);
                }
                else
                {
                    switch (Configuration.currentLanguage)
                    {
                    case CR_TTLangue.French_Canada:
                    {
                        Toast.MakeText(this, "Mot de passe invalide", ToastLength.Short).Show();
                        break;
                    }

                    case CR_TTLangue.English:
                    {
                        Toast.MakeText(this, "Invalid password", ToastLength.Short).Show();
                        break;
                    }
                    }
                }
            };
        }
 /// <summary>
 /// Here we are trying to get a callback from a WiseJ WebMethod, but its not working. result is always null.
 /// https://wisej.com/support/question/forcing-form-toolbutton-click-with-javascript#sabai-entity-content-9216
 /// </summary>
 /// <param name="result"></param>
 public void OnReceiveValue(Java.Lang.Object result)
 {
     if (result.ToString() == "False")
     {
         JavaSystem.Exit(0);
     }
 }
Example #5
0
 public void closeApplication()
 {
     //var activity = (Activity)Forms.Context;
     //activity.FinishAffinity();
     //Android.OS.Process.KillProcess(Android.OS.Process.MyPid());
     JavaSystem.Exit(0);
 }
 public void OnDismiss(IDialogInterface dialog)
 {
     if (_weakActivity.TryGetTarget(out Activity activity))
     {
         activity.Finish();
         JavaSystem.Exit(0);
     }
 }
Example #7
0
 internal static void ShowCriticalError(Context context, string message)
 {
     AlertDialog.Builder builder = new AlertDialog.Builder(context);
     builder.SetTitle("Error");
     builder.SetMessage(message);
     builder.SetPositiveButton("Exit", (sender, args) => JavaSystem.Exit(0));
     builder.SetCancelable(false);
     builder.Show();
 }
        public override void OnBackPressed()
        {
            var pressTime = DateTime.Now;

            if ((pressTime - _lastPressTime).TotalMilliseconds <= _doublePressInterval_ms)
            {
                JavaSystem.Exit(0);
            }
            Toast.MakeText(this, "Press agian to exit ... ", ToastLength.Short).Show();
            _lastPressTime = pressTime;
        }
Example #9
0
 public void UncaughtException(Thread t, Throwable e)
 {
     if (!HandleException(e) && mDefaultHandler != null)
     {
         mDefaultHandler.UncaughtException(t, e);
     }
     else
     {
         Android.OS.Process.KillProcess(Android.OS.Process.MyPid());
         JavaSystem.Exit(1);
     }
 }
Example #10
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            SetContentView(Resource.Layout.offlineActivity);

            var exitBtn = FindViewById <Button>(Resource.Id.giveupButton);

            exitBtn.Click += (sender, e) => {
                JavaSystem.Exit(0);
            };
            // Create your application here
        }
Example #11
0
 public void AppExit(Context context)
 {
     try
     {
         FinishAllActivity();
         var activityMgr = context.GetSystemService(Context.ActivityService).JavaCast <ActivityManager>();
         activityMgr.KillBackgroundProcesses(context.PackageName);
         JavaSystem.Exit(0);
     }
     catch (System.Exception e)
     {
         LoggerFactory.Current.Create().LogError(e.Message);
     }
 }
Example #12
0
        public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Permission[] grantResults)
        {
            Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);
            if (requestCode == (int)RequestCodes.CameraPermissionRequestCode ||
                requestCode == (int)RequestCodes.WriteToStorageRequestCode)
            {
                if (!grantResults.Contains(Permission.Granted))
                {
                    JavaSystem.Exit(0);
                    return;
                }
            }

            if (requestCode == (int)RequestCodes.BluetoothBasicRequestCode ||
                requestCode == (int)RequestCodes.BluetoothAdminRequestCode)
            {
                if (!grantResults.Contains(Permission.Granted))
                {
                    PlatformBluetooth.BluetoothPermissionsTask.SetResult(false);
                    return;
                }

                CheckForAndRequestBluetoothPermissions();
                return;
            }

            if (requestCode == (int)RequestCodes.FineLocationRequestCode ||
                requestCode == (int)RequestCodes.CoarseLocationRequestCode)
            {
                if (!grantResults.Contains(Permission.Granted))
                {
                    PlatformBluetooth.LocationPermissionsTask.SetResult(false);
                    return;
                }

                CheckForAndRequestLocationPermissions();
                return;
            }

            if (CheckForAndRequestRequiredPermissions())
            {
                return;
            }

            _app = new App();
            LoadApplication(_app);

            base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
        }
Example #13
0
        public void closeApplication()
        {
            JavaSystem.Exit(0);

            /*try
             * {
             *  //var activity = (Activity)Android.App.Application.Context;
             *  //activity.FinishAffinity();
             *
             * }
             * catch (Exception e)
             * {
             *  throw new Exception("caught it where i thought");
             * }*/
        }
        private void AndroidEnvironment_UnhandledExceptionRaiser(object sender, RaiseThrowableEventArgs e)
        {
            var intent = new Intent(activity, typeof(MainActivity));

            intent.PutExtra("crash", true);
            intent.AddFlags(ActivityFlags.ClearTop | ActivityFlags.ClearTask | ActivityFlags.NewTask);

            var pendingIntent = PendingIntent.GetActivity(MainApplication.instance, 0, intent, PendingIntentFlags.OneShot);

            var mgr = (AlarmManager)MainApplication.instance.GetSystemService(Context.AlarmService);

            mgr.Set(AlarmType.Rtc, DateTime.Now.Millisecond + 5, pendingIntent);

            activity.Finish();
            JavaSystem.Exit(2);
        }
Example #15
0
        private void restartApp()
        {
            var intent = new Intent(activity, typeof(MainActivity));

            intent.PutExtra("crash", true);
            intent.AddFlags(ActivityFlags.ClearTop | ActivityFlags.ClearTask | ActivityFlags.NewTask);

            var pendingIntent = PendingIntent.GetActivity(MainActivity.instance, 0, intent, PendingIntentFlags.OneShot);

            var mgr = (AlarmManager)MainActivity.instance.GetSystemService(Context.AlarmService);

            mgr.Set(AlarmType.Rtc, DateTime.Now.Millisecond + 100, pendingIntent);

            activity.Finish();

            JavaSystem.Exit(2);
        }
 protected override void OnElementChanged(ElementChangedEventArgs <ArguSzem.ViewModels.CameraPreview> e)
 {
     base.OnElementChanged(e);
     if (e.NewElement != null)
     {
         if (Control == null)
         {
             cameraPreview = new CameraPreview(Context);
             SetNativeControl(cameraPreview);
         }
         try
         {
             Control.Preview = Camera.Open((int)e.NewElement.Camera);
         }
         catch
         {
             JavaSystem.Exit(0);
         }
     }
 }
Example #17
0
        private void AndroidEnvironmentOnUnhandledExceptionRaiser(object sender, RaiseThrowableEventArgs e)
        {
            try
            {
                Intent intent = new Intent(this.activity, typeof(SpalshScreen_Activity));
                intent.AddCategory(Intent.CategoryHome);
                intent.PutExtra("crash", true);
                intent.SetAction(Intent.ActionMain);
                intent.AddFlags(ActivityFlags.ClearTop | ActivityFlags.NewTask | ActivityFlags.ClearTask);

                PendingIntent pendingIntent = PendingIntent.GetActivity(MainApplication.GetInstance().BaseContext, 0, intent, PendingIntentFlags.OneShot);
                AlarmManager  mgr           = (AlarmManager)MainApplication.GetInstance().BaseContext.GetSystemService(Context.AlarmService);
                mgr.Set(AlarmType.Rtc, JavaSystem.CurrentTimeMillis() + 100, pendingIntent);

                this.activity.Finish();
                JavaSystem.Exit(2);
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
Example #18
0
        private void AndroidEnvironmentOnUnhandledExceptionRaiser(object sender, RaiseThrowableEventArgs e)
        {
            try
            {
                Intent intent = new Intent(Activity, typeof(SplashScreenActivity));
                intent.AddCategory(Intent.CategoryHome);
                intent.PutExtra("crash", true);
                intent.SetAction(Intent.ActionMain);
                intent.AddFlags(ActivityFlags.ClearTop | ActivityFlags.NewTask | ActivityFlags.ClearTask);

                PendingIntent pendingIntent = PendingIntent.GetActivity(GetInstance().BaseContext, 0, intent, PendingIntentFlags.OneShot);
                AlarmManager  mgr           = (AlarmManager)GetInstance()?.BaseContext?.GetSystemService(AlarmService);
                mgr?.Set(AlarmType.Rtc, JavaSystem.CurrentTimeMillis() + 100, pendingIntent);

                Activity.Finish();
                JavaSystem.Exit(2);
            }
            catch (Exception exception)
            {
                Methods.DisplayReportResultTrack(exception);
            }
        }
Example #19
0
 public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Permission[] grantResults)
 {
     Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);
     if (requestCode == CAMERA_PERMISSION_REQUEST_CODE)
     {
         if (grantResults.Contains(Permission.Granted))
         {
             if (ContextCompat.CheckSelfPermission(Forms.Context, Manifest.Permission.WriteExternalStorage) !=
                 (int)Permission.Granted)
             {
                 ActivityCompat.RequestPermissions(Instance, new[] { Manifest.Permission.WriteExternalStorage },
                                                   WRITE_TO_STORAGE_REQUEST_CODE);
             }
             else
             {
                 _app = new App();
                 LoadApplication(_app);
             }
         }
         else
         {
             JavaSystem.Exit(0);
         }
     }
     else if (requestCode == WRITE_TO_STORAGE_REQUEST_CODE)
     {
         if (grantResults.Contains(Permission.Granted))
         {
             _app = new App();
             LoadApplication(_app);
         }
         else
         {
             JavaSystem.Exit(0);
         }
     }
     base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
 }
Example #20
0
        public override void OnBackPressed()
        {
            int  cont        = 0;
            long currentTime = DateTime.UtcNow.Ticks / TimeSpan.TicksPerMillisecond;

            if (((VeciHelpAPK.App)App.Current).PromptToConfirmExit)
            {
                if (currentTime - lastPress > 5000)
                {
                    Toast.MakeText(this, "Presione 2 veces para Salir", ToastLength.Long).Show();
                    lastPress = currentTime;
                    cont++;
                }
                else
                {
                    JavaSystem.Exit(0);
                }
            }
            else
            {
                base.OnBackPressed();
            }
        }
Example #21
0
        /// <summary>
        /// 当UncaughtException发生时会转入该函数来处理
        /// </summary>
        /// <param name="thread"></param>
        /// <param name="ex"></param>
        public void UncaughtException(Thread thread, Throwable ex)
        {
            if (!HandleException(ex) && mDefaultHandler != null)
            {
                //如果用户没有处理则让系统默认的异常处理器来处理
                mDefaultHandler.UncaughtException(thread, ex);
            }
            else
            {
                //new Thread(() =>
                //{
                //    Looper.Prepare();
                //    ToastUtils.ShowSingleToast($"很抱歉,程序出现异常,即将重启:{ex.Message}");
                //    Looper.Loop();
                //}).Start();

                ////展示的时间
                //Thread.Sleep(5000);

                //退出程序
                Process.KillProcess(Process.MyPid());
                JavaSystem.Exit(1);
            }
        }
Example #22
0
 public void Terminate()
 {
     this.FinishAffinity();
     JavaSystem.Exit(0);
 }
 public void CloseApp()
 {
     JavaSystem.Exit(0);
 }
Example #24
0
 public void OnClick(object dialog, DialogClickEventArgs e)
 {
     Locator.Current.GetService <FavoriteMoviesPageViewModel>().Dispose();
     activity.FinishAffinity();
     JavaSystem.Exit(0);
 }
Example #25
0
 private void btnClose_Clicked(object sender, EventArgs e)
 {
     JavaSystem.Exit(0);
 }
 public void CloseApplication()
 {
     JavaSystem.Exit(0);
 }
Example #27
0
        protected override void OnDestroy()
        {
            base.OnDestroy();

            JavaSystem.Exit(0);
        }
Example #28
0
 private void Button_OnClicked(object sender, EventArgs e)
 {
     JavaSystem.Exit(0);
 }
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var view = inflater.Inflate(Resource.Layout.LoginDialog, container, false);

            UserNameTxt = view.FindViewById <EditText>(Resource.Id.Login_EmailTxt);
            PasswordTxt = view.FindViewById <EditText>(Resource.Id.Login_PasswordTxt);
            view.FindViewById <Button>(Resource.Id.Login_LoginButton).Click += LoginButtonClicked;
            view.FindViewById <Button>(Resource.Id.Login_QuitButton).Click  += (sender, args) => JavaSystem.Exit(0);
            return(view);
        }