void CheckGS()
        {
            _isGooglePlayServicesAvailable = GooglePlayServicesUtil.IsGooglePlayServicesAvailable(this);

            try
            {
                _addAlarmMenuButton.SetVisible(_isGooglePlayServicesAvailable == ConnectionResult.Success && Mode == Screens.Mode.None);
            }
            catch (Exception e)
            {
            }

            if (_isGooglePlayServicesAvailable != ConnectionResult.Success)
            {
                if (GooglePlayServicesUtil.IsUserRecoverableError(_isGooglePlayServicesAvailable))
                {
                    GooglePlayServicesUtil.ShowErrorDialogFragment(_isGooglePlayServicesAvailable, this, _googleServicesCheckRequestCode);
                }
                else
                {
                    ShowToast(Resource.String.device_not_supported);
                    Finish();
                }
            }
        }
Beispiel #2
0
        void ShowErrorDialog(ConnectionResult connectionResult)
        {
            int errorCode = connectionResult.ErrorCode;

            if (GooglePlayServicesUtil.IsUserRecoverableError(errorCode))
            {
                var listener = new DialogInterfaceOnCancelListener();
                listener.OnCancelImpl = (dialog) =>
                {
                    mShouldResolve = false;
                    // UpdateUI(false);
                };
                GooglePlayServicesUtil.GetErrorDialog(errorCode, this, RC_SIGN_IN, listener).Show();
            }
            else
            {
                //var errorstring = string.Format(GetString(Resource.String.play_services_error_fmt), errorCode);
                //Toast.MakeText(this, errorstring, ToastLength.Short).Show();

                mShouldResolve = false;
                //UpdateUI(false);
            }
            HandleResult(new GoogleLoginResult {
                IsSuccess = false, Message = connectionResult.ErrorMessage
            });
        }
        protected bool ReadyToGo()
        {
            int status = GooglePlayServicesUtil.IsGooglePlayServicesAvailable(this);

            if (status == ConnectionResult.Success)
            {
                if (GetVersionFromPackageManager(this) >= 2)
                {
                    return(true);
                }
                else
                {
                    Toast.MakeText(this, Resource.String.no_maps, ToastLength.Long).Show();
                    Finish();
                }
            }
            else if (GooglePlayServicesUtil.IsUserRecoverableError(status))
            {
                ErrorDialogFragment e = new ErrorDialogFragment();

                e.NewInstance(status).Show(FragmentManager, TAG_ERROR_DIALOG_FRAGMENT);
            }
            else
            {
                Toast.MakeText(this, Resource.String.no_maps, ToastLength.Long).Show();
                Finish();
            }

            return(false);
        }
        protected override Dialog OnCreateDialog(int id)
        {
            if (id != DIALOG_GET_GOOGLE_PLAY_SERVICES)
            {
                return(base.OnCreateDialog(id));
            }

            int available = GooglePlayServicesUtil.IsGooglePlayServicesAvailable(this);

            if (available == CommonStatusCodes.Success)
            {
                return(null);
            }

            if (GooglePlayServicesUtil.IsUserRecoverableError(available))
            {
                return(GooglePlayServicesUtil.GetErrorDialog(
                           available, this, REQUEST_CODE_GET_GOOGLE_PLAY_SERVICES, this));
            }
            return(new AlertDialog.Builder(this)
                   .SetMessage(Resource.String.plus_generic_error)
                   .SetCancelable(true)
                   .SetOnCancelListener(this)
                   .Create());
        }
        private bool CheckPlayServices()
        {
            var context = Mvx.Resolve <IMvxAndroidCurrentTopActivity>().Activity;

            var resultCode = GooglePlayServicesUtil.IsGooglePlayServicesAvailable(context);

            if (resultCode == ConnectionResult.Success)
            {
                return(true);
            }

            if (GooglePlayServicesUtil.IsUserRecoverableError(resultCode))
            {
                GooglePlayServicesUtil.GetErrorDialog(resultCode, context, 9000);
            }
            else
            {
                if (Error != null)
                {
                    Error(this, new NotificationErrorEventArgs
                    {
                        Message = "This device is not supported"
                    });
                }
            }
            return(false);
        }
        // Utility method to check for the presence of the Google Play Services APK:
        public bool IsPlayServicesAvailable()
        {
            // These methods are moving to GoogleApiAvailability soon:
            int resultCode = GooglePlayServicesUtil.IsGooglePlayServicesAvailable(this);

            if (resultCode != ConnectionResult.Success)
            {
                // Google Play Service check failed - display the error to the user:
                if (GooglePlayServicesUtil.IsUserRecoverableError(resultCode))
                {
                    // Give the user a chance to download the APK:
                    msgText.Text = GooglePlayServicesUtil.GetErrorString(resultCode);
                }
                else
                {
                    msgText.Text = "Sorry, this device is not supported";
                    Finish();
                }
                return(false);
            }
            else
            {
                msgText.Text = "Google Play Services is available.";
                return(true);
            }
        }
Beispiel #7
0
        // Perform resolution given a non-null result.
        private void resolveLastResult()
        {
            if (GooglePlayServicesUtil.IsUserRecoverableError(mLastConnectionResult.GetErrorCode()))
            {
                // Show a dialog to install or enable Google Play services.
                showErrorDialog(ErrorDialogFragment.Create(mLastConnectionResult.GetErrorCode(),
                                                           mRequestCode));
                return;
            }

            if (mLastConnectionResult.HasResolution())
            {
                startResolution();
            }
        }
Beispiel #8
0
            void CheckOldGooglePlayServices(Activity activity)
            {
                var isAvailable = GooglePlayServicesUtil.IsGooglePlayServicesAvailable(activity);

                if (isAvailable != ConnectionResult.Success)
                {
                    if (GooglePlayServicesUtil.IsUserRecoverableError(isAvailable))
                    {
                        var dialog = GooglePlayServicesUtil.GetErrorDialog(isAvailable, activity, SIGN_IN_REQUEST_CODE);
                        dialog.Show();
                        throw new Exception(GooglePlayServicesUtil.GetErrorString(isAvailable));
                    }
                    else
                    {
                        throw new Exception("This device is not Supported");
                    }
                }
            }
        public static bool CheckPlayServices(Activity context)
        {
            int result = GooglePlayServicesUtil.IsGooglePlayServicesAvailable(context);

            if (result != ConnectionResult.Success)
            {
                if (GooglePlayServicesUtil.IsUserRecoverableError(result))
                {
                    GooglePlayServicesUtil.GetErrorDialog(result, context, PLAY_SERVICE_RESOLUTION_REQ).Show();
                }
                else
                {
                    Log.Debug("GetMapAsync", "Google Play Services is not supported on this device");
                    context.Finish();
                }
                return(false);
            }
            return(true);           //we're good
        }
Beispiel #10
0
        private bool CheckPlayServices()
        {
            int resultCode = GooglePlayServicesUtil.IsGooglePlayServicesAvailable(this);

            if (resultCode != ConnectionResult.Success)
            {
                if (GooglePlayServicesUtil.IsUserRecoverableError(resultCode))
                {
                    GooglePlayServicesUtil.GetErrorDialog(resultCode, this, PLAY_SERVICES_RESOLUTION_REQUEST).Show();
                }
                else
                {
                    Log.Info(TAG, "This device is not supported.");
                    Finish();
                }
                return(false);
            }
            return(true);
        }
Beispiel #11
0
        bool IsGooglePlayServicesInstalled()
        {
            int queryResult = GooglePlayServicesUtil.IsGooglePlayServicesAvailable(this);

            if (queryResult == ConnectionResult.Success)
            {
                Log.Info("MainActivity", "Google Play Services is installed on this device.");
                return(true);
            }

            if (GooglePlayServicesUtil.IsUserRecoverableError(queryResult))
            {
                string errorString = GooglePlayServicesUtil.GetErrorString(queryResult);
                Log.Error("ManActivity", "There is a problem with Google Play Services on this device: {0} - {1}", queryResult, errorString);

                // Show error dialog to let user debug google play services
            }
            return(false);
        }
        private bool TestIfGooglePlayServicesIsInstalled()
        {
            var queryResult = GooglePlayServicesUtil.IsGooglePlayServicesAvailable(this);

            if (queryResult == ConnectionResult.Success)
            {
                Log.Info("AppCompatAndMaps", "Google Play Services is installed on this device.");
                return(true);
            }

            if (GooglePlayServicesUtil.IsUserRecoverableError(queryResult))
            {
                var errorString = GooglePlayServicesUtil.GetErrorString(queryResult);
                Log.Error("AppCompatAndMaps", "There is a problem with Google Play Services on this device: {0} - {1}", queryResult, errorString);
                var errorDialog = GooglePlayServicesUtil.GetErrorDialog(queryResult, this, InstallGooglePlayServicesId);
                errorDialog.Show();
            }
            return(false);
        }
        private bool CheckPlayServices()
        {
            int resultCode = GooglePlayServicesUtil.IsGooglePlayServicesAvailable(this);

            if (resultCode != ConnectionResult.Success)
            {
                if (GooglePlayServicesUtil.IsUserRecoverableError(resultCode))
                {
                    GooglePlayServicesUtil.GetErrorDialog(resultCode, this, PLAY_SERVICES_RESOLUTION_REQUEST).Show();
                }
                else
                {
                    Toast.MakeText(ApplicationContext, "This device does not support Google Play Services", ToastLength.Long).Show();
                    Finish();
                }
                return(false);
            }
            return(true);
        }
        /**
         * Helper to try to resolve a user recoverable error (i.e. the user has an out of date version
         * of Google Play Services installed), via an error dialog provided by
         * {@link GooglePlayServicesUtil#getErrorDialog(int, Activity, int, OnCancelListener)}. If an,
         * error is not user recoverable then the error will be handled in {@link #handleError(int)}.
         */
        protected void resolveUnsuccessfulConnectionResult()
        {
            // Additional user input is needed
            if (mConnectionResult.HasResolution)
            {
                try {
                    mConnectionResult.StartResolutionForResult(Activity, REQUEST_CODE_RESOLVE_ERR);
                } catch (IntentSender.SendIntentException) {
                    reconnect();
                }
            }
            else
            {
                int errorCode = mConnectionResult.ErrorCode;
                if (GooglePlayServicesUtil.IsUserRecoverableError(errorCode))
                {
                    var dialog = GooglePlayServicesUtil.GetErrorDialog(errorCode, Activity, REQUEST_CODE_RESOLVE_ERR, this);

                    // the dialog will either be dismissed, which will invoke the OnCancelListener, or
                    // the dialog will be addressed, which will result in a callback to
                    // OnActivityResult()
                    dialog.Show();
                }
                else
                {
                    switch (errorCode)
                    {
                    case ConnectionResult.InternalError:
                    case ConnectionResult.NetworkError:
                        reconnect();
                        break;

                    default:
                        handleError(errorCode);
                        break;
                    }
                }
            }

            mConnectionResult = null;
        }
Beispiel #15
0
        private bool TestIfGooglePlayServicesIsInstalled()
        {
            int queryResult = GooglePlayServicesUtil.IsGooglePlayServicesAvailable(this);

            if (queryResult == ConnectionResult.Success)
            {
                Log.Info(Tag, "Google Play Services is installed on this device.");
                return(true);
            }

            if (GooglePlayServicesUtil.IsUserRecoverableError(queryResult))
            {
                string errorString = GooglePlayServicesUtil.GetErrorString(queryResult);
                Log.Error(Tag, "There is a problem with Google Play Services on this device: {0} - {1}", queryResult, errorString);
                Dialog errorDialog             = GooglePlayServicesUtil.GetErrorDialog(queryResult, this, InstallGooglePlayServicesId);
                ErrorDialogFragment dialogFrag = new ErrorDialogFragment(errorDialog);

                dialogFrag.Show(FragmentManager, "GooglePlayServicesDialog");
            }
            return(false);
        }
        void ShowErrorDialog(ConnectionResult connectionResult)
        {
            int errorCode = connectionResult.ErrorCode;

            if (GooglePlayServicesUtil.IsUserRecoverableError(errorCode))
            {
                var listener = new DialogInterfaceOnCancelListener();
                listener.OnCancelImpl = (dialog) =>
                {
                    mShouldResolve = false;
                };
                GooglePlayServicesUtil.GetErrorDialog(errorCode, this, RC_SIGN_IN, listener).Show();
            }
            else
            {
                mShouldResolve = false;
            }
            HandleResult(new GoogleLoginResult {
                IsSuccess = false, Message = connectionResult.ErrorMessage
            });
        }
        /// <summary>
        /// Retourne vrai si les services google play sont disponnible sur le device exécutant l'appli
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public static bool IsPlayServicesAvailable(Context context)
        {
            int resultCode = GooglePlayServicesUtil.IsGooglePlayServicesAvailable(context);

            if (resultCode != ConnectionResult.Success)
            {
                if (GooglePlayServicesUtil.IsUserRecoverableError(resultCode))
                {
                    Console.WriteLine(GooglePlayServicesUtil.GetErrorString(resultCode));
                }
                else
                {
                    Console.WriteLine("Sorry, this device is not supported");
                }
                return(false);
            }
            else
            {
                Console.WriteLine("Google Play Services is available");
                return(true);
            }
        }
Beispiel #18
0
        void ShowErrorDialog(ConnectionResult connectionResult)
        {
            int errorCode = connectionResult.ErrorCode;

            if (GooglePlayServicesUtil.IsUserRecoverableError(errorCode))
            {
                var listener = new DialogInterfaceOnCancelListener();
                listener.OnCancelImpl = (dialog) => {
                    mShouldResolve = false;
                    UpdateUI(false);
                };
                GooglePlayServicesUtil.GetErrorDialog(errorCode, this, RC_SIGN_IN, listener).Show();
            }
            else
            {
                var errorstring = string.Format("{0}", errorCode);
                Toast.MakeText(this, errorstring, ToastLength.Short).Show();

                mShouldResolve = false;
                UpdateUI(false);
            }
        }
Beispiel #19
0
        public bool IsPlayServicesAvailable()
        {
            int resultCode = GooglePlayServicesUtil.IsGooglePlayServicesAvailable(this);

            if (resultCode != ConnectionResult.Success)
            {
                if (GooglePlayServicesUtil.IsUserRecoverableError(resultCode))
                {
                    txtmsg.Text = GooglePlayServicesUtil.GetErrorString(resultCode);
                }
                else
                {
                    Toast.MakeText(this, "Sorry, this device is not supported", ToastLength.Short).Show();
                    Finish();
                }
                return(false);
            }
            else
            {
                Toast.MakeText(this, "Google Play Services is available.", ToastLength.Short).Show();
                return(true);
            }
        }
Beispiel #20
0
        public bool IsPlayServicesAvailable()
        {
            int resultCode = GooglePlayServicesUtil.IsGooglePlayServicesAvailable(this);
            var left       = FindViewById <TextView> (Resource.Id.Left);

            if (resultCode != ConnectionResult.Success)
            {
                if (GooglePlayServicesUtil.IsUserRecoverableError(resultCode))
                {
                    left.Text = GooglePlayServicesUtil.GetErrorString(resultCode);
                }
                else
                {
                    left.Text = "Sorry, this device is not supported";
                    Finish();
                }
                return(false);
            }
            else
            {
                left.Text = "Google Play Services is available.";
                return(true);
            }
        }