public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults)
        {
            if (!ARLocationPermissionHelper.HasPermission(this))
            {
                if (!ARLocationPermissionHelper.ShouldShowRequestPermissionRationale(this))
                {
                    // Permission denied with checking "Do not ask again".
                    ARLocationPermissionHelper.LaunchPermissionSettings(this);
                }
                else
                {
                    Toast.MakeText(this, "Camera permission is needed to run this application", ToastLength.Long).Show();
                }

                Finish();
            }

            base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
        }
        public static Session CreateArSession(Activity activity, bool installRequested)
        {
            Session session = null;

            // if we have the camera permission, create the session
            if (ARLocationPermissionHelper.HasPermission(activity))
            {
                //switch (ArCoreApk.Instance.RequestInstall(activity, !installRequested))
                //{
                //    case "INSTALL_REQUESTED":
                //        return null;
                //    case "INSTALLED":
                //        break;
                //}
                session = new Session(activity);
                // IMPORTANT!!!  ArSceneView needs to use the non-blocking update mode.
                Config config = new Config(session);
                config.SetUpdateMode(Config.UpdateMode.LatestCameraImage);
                session.Configure(config);
            }

            return(session);
        }
        protected override void OnResume()
        {
            base.OnResume();

            if (locationScene != null)
            {
                locationScene.Resume();
            }

            if (arSceneView.Session == null)
            {
                // If the session wasn't created yet, don't resume rendering.
                // This can happen if ARCore needs to be updated or permissions are not granted yet.
                try
                {
                    Session session = CreateArSession(this, installRequested);
                    if (session == null)
                    {
                        installRequested = ARLocationPermissionHelper.HasPermission(this);
                        return;
                    }
                    else
                    {
                        arSceneView.SetupSession(session);
                    }
                }
                catch (UnavailableException e)
                {
                    string message;
                    if (e is UnavailableArcoreNotInstalledException)
                    {
                        message = "Please install ARCore";
                    }
                    else if (e is UnavailableApkTooOldException)
                    {
                        message = "Please update ARCore";
                    }
                    else if (e is UnavailableSdkTooOldException)
                    {
                        message = "Please update this app";
                    }
                    else if (e is UnavailableDeviceNotCompatibleException)
                    {
                        message = "This device does not support AR";
                    }
                    else
                    {
                        message = "Failed to create AR session";
                    }
                    Toast.MakeText(this, message, ToastLength.Long).Show();
                }
            }

            try
            {
                arSceneView.Resume();
            }
            catch (System.Exception ex)
            {
                Finish();
                return;
            }

            if (arSceneView.Session != null)
            {
                ShowLoadingMessage();
            }
        }