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);
        }
        public static void Init(Activity activity, Bundle bundle, PlatformConfig config = null, int MapStyleResourceId = 0)
        {
            if (IsInitialized)
            {
                return;
            }

            Context = activity;

            MapRenderer.Bundle = bundle;
            MapRenderer.Config = config ?? new PlatformConfig();
            ResourceId         = MapStyleResourceId;

#pragma warning disable 618
            if (GooglePlayServicesUtil.IsGooglePlayServicesAvailable(Context) == ConnectionResult.Success)
#pragma warning restore 618
            {
                try
                {
                    MapsInitializer.Initialize(Context);
                    IsInitialized = true;
                }
                catch (Exception e)
                {
                    Console.WriteLine("Google Play Services Not Found");
                    Console.WriteLine("Exception: {0}", e);
                }
            }

            GeocoderBackend.Register(Context);
        }
Beispiel #3
0
        /// <summary>
        /// Attempt to Sign in to Google Play
        /// </summary>
        public void SignIn()
        {
            signingin = true;
            if (client == null)
            {
                CreateClient();
            }

            if (client.IsConnected)
            {
                return;
            }

            if (client.IsConnecting)
            {
                return;
            }

            var result = GooglePlayServicesUtil.IsGooglePlayServicesAvailable(activity);

            if (result != ConnectionResult.Success)
            {
                return;
            }

            Start();
        }
Beispiel #4
0
        bool IsPlayServiceAvailable()
        {
            var resultCode = GooglePlayServicesUtil.IsGooglePlayServicesAvailable(this);

            // If Google Play services is available
            return(ConnectionResult.Success == resultCode);
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.person_list_activity);

            var options = new PlusClass.PlusOptions.Builder()
                          .AddActivityTypes(MomentUtil.ACTIONS).Build();

            mGoogleApiClient = new GoogleApiClientBuilder(this)
                               .AddConnectionCallbacks(this)
                               .AddOnConnectionFailedListener(this)
                               .AddApi(PlusClass.API, options)
                               .AddScope(PlusClass.ScopePlusLogin)
                               .Build();

            mListItems   = new List <String>();
            mListAdapter = new ArrayAdapter <String>(this,
                                                     Android.Resource.Layout.SimpleListItem1, mListItems);
            mPersonListView = FindViewById <ListView> (Resource.Id.person_list);
            mResolvingError = savedInstanceState != null &&
                              savedInstanceState.GetBoolean(STATE_RESOLVING_ERROR, false);

            int available = GooglePlayServicesUtil.IsGooglePlayServicesAvailable(this);

            if (available != CommonStatusCodes.Success)
            {
                ShowDialog(DIALOG_GET_GOOGLE_PLAY_SERVICES);
            }

            if (Build.VERSION.SdkInt >= BuildVersionCodes.Honeycomb)
            {
                this.ActionBar.SetDisplayHomeAsUpEnabled(true);
            }
        }
Beispiel #6
0
        public static void Init(Activity activity, Bundle bundle)
        {
            if (IsInitialized)
            {
                return;
            }
            IsInitialized = true;

#pragma warning disable 618 // Setting this to support custom code which may still depend on it
            Context = activity;
#pragma warning restore 618

            MapRenderer.Bundle = bundle;

#pragma warning disable 618
            if (GooglePlayServicesUtil.IsGooglePlayServicesAvailable(activity) == ConnectionResult.Success)
#pragma warning restore 618
            {
                try
                {
                    MapsInitializer.Initialize(activity);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Google Play Services Not Found");
                    Console.WriteLine("Exception: {0}", e);
                }
            }

            new GeocoderBackend(activity).Register();
        }
        public void GetGoogleLicense()
        {
            String txt;
            var    lblAboutMaps = FindViewById <TextView>(Resource.Id.lblMaps);

            try
            {
                if (GooglePlayServicesUtil.IsGooglePlayServicesAvailable(this) == ConnectionResult.Success)
                {
                    txt = GooglePlayServicesUtil.GetOpenSourceSoftwareLicenseInfo(this);
                    if (txt != null)
                    {
                        RunOnUiThread(() => lblAboutMaps.Text = txt);
                    }
                    else
                    {
                        RunOnUiThread(() => lblAboutMaps.Text = "");
                    }
                }
            }
            catch (Exception ex)
            {
                RunOnUiThread(() => lblAboutMaps.Text = ex.Message);
            }
        }
        public static void Init(Activity activity, Bundle bundle)
        {
            if (IsInitialized)
            {
                return;
            }

            Context = activity;

            TKCustomMapRenderer.Bundle = bundle;

#pragma warning disable 618
            if (GooglePlayServicesUtil.IsGooglePlayServicesAvailable(Context) == ConnectionResult.Success)
#pragma warning restore 618
            {
                try
                {
                    MapsInitializer.Initialize(Context);
                    IsInitialized = true;
                }
                catch (Exception e)
                {
                    Console.WriteLine("Google Play Services Not Found");
                    Console.WriteLine("Exception: {0}", e);
                }
            }
        }
        public void BeginUserInitiatedSignIn()
        {
            if (signedIn)
            {
                return;
            }

            autoSignIn = true;

            int result = GooglePlayServicesUtil.IsGooglePlayServicesAvailable(activity);

            if (result != ConnectionResult.Success)
            {
                Dialog errorDialog = ErrorDialog(result);
                errorDialog.Show();
                if (listener != null)
                {
                    listener.OnSignInFailed();
                }
                return;
            }

            userInitiatedSignIn = true;
            if (connectionResult != null)
            {
                ShowProgressDialog(true);
                ResolveConnectionResult();
            }
            else
            {
                StartConnections();
            }
        }
        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());
        }
        public void Login()
        {
            _signingIn = true;

            if (_client == null)
            {
                CreateClient();
            }

            if (_client.IsConnected)
            {
                return;
            }

            if (_client.IsConnecting)
            {
                return;
            }

            var result = GooglePlayServicesUtil.IsGooglePlayServicesAvailable(AppMain.Activity);

            if (result != ConnectionResult.Success)
            {
                return;
            }

            Start();
        }
        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);
        }
        // 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);
            }
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.share_activity);

            var sendButton = FindViewById <Button>(Resource.Id.send_interactive_button);

            sendButton.Click += (sender, e) => {
                StartActivityForResult(getInteractivePostIntent(), REQUEST_CODE_INTERACTIVE_POST);
            };

            mEditSendText = FindViewById <EditText> (Resource.Id.share_prefill_edit);
            var available = GooglePlayServicesUtil.IsGooglePlayServicesAvailable(this);

            if (available != ConnectionResult.Success)
            {
                ShowDialog(DIALOG_GET_GOOGLE_PLAY_SERVICES);
            }

            if (Build.VERSION.SdkInt >= BuildVersionCodes.Honeycomb)
            {
                ActionBar.SetDisplayHomeAsUpEnabled(true);
            }
        }
        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 #16
0
        public bool IsPlayServicesAvailable()
        {
            int resultCode = GooglePlayServicesUtil.IsGooglePlayServicesAvailable(Forms.Context);

            if (resultCode != ConnectionResult.Success)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.list_moments_activity);

            var options = new PlusClass.PlusOptions.Builder()
                          .AddActivityTypes(MomentUtil.ACTIONS).Build();

            mGoogleApiClient = new GoogleApiClientBuilder(this)
                               .AddConnectionCallbacks(this)
                               .AddOnConnectionFailedListener(this)
                               .AddApi(PlusClass.API, options)
                               .AddScope(PlusClass.ScopePlusLogin)
                               .Build();

            mListItems                 = new List <IMoment>();
            mMomentListAdapter         = new MomentListAdapter(this, Android.Resource.Layout.SimpleListItem1, mListItems);
            mMomentListView            = FindViewById <ListView> (Resource.Id.moment_list);
            mMomentListView.ItemClick += (sender, e) => {
                var moment = mMomentListAdapter.GetItem(e.Position);
                if (moment != null)
                {
                    if (mGoogleApiClient.IsConnected)
                    {
                        PlusClass.MomentsApi.Remove(mGoogleApiClient, moment.Id);
                        Toast.MakeText(this, GetString(Resource.String.plus_remove_moment_status),
                                       ToastLength.Short).Show();
                    }
                    else
                    {
                        Toast.MakeText(this, GetString(Resource.String.greeting_status_sign_in_required),
                                       ToastLength.Short).Show();
                    }
                }
            };

            mResolvingError = savedInstanceState != null &&
                              savedInstanceState.GetBoolean(STATE_RESOLVING_ERROR, false);

            int available = GooglePlayServicesUtil.IsGooglePlayServicesAvailable(this);

            if (available != CommonStatusCodes.Success)
            {
                ShowDialog(DIALOG_GET_GOOGLE_PLAY_SERVICES);
            }

            if (Build.VERSION.SdkInt >= BuildVersionCodes.Honeycomb)
            {
                this.ActionBar.SetDisplayHomeAsUpEnabled(true);
            }
        }
Beispiel #18
0
		bool CheckGooglePlayServices ()
		{
			var result = GooglePlayServicesUtil.IsGooglePlayServicesAvailable (this);
			if (result == ConnectionResult.Success)
				return true;
			var dialog = GooglePlayServicesUtil.GetErrorDialog (result,
			                                                    this,
			                                                    ConnectionFailureResolutionRequest);
			if (dialog != null) {
				var errorDialog = new ErrorDialogFragment { Dialog = dialog };
				errorDialog.Show (SupportFragmentManager, "Google Services Updates");
				return false;
			}

			Finish ();
			return false;
		}
Beispiel #19
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");
                    }
                }
            }
Beispiel #20
0
 protected override void OnCreate(Bundle savedInstance)
 {
     base.OnCreate(savedInstance);
     // Calling this method triggers a validation error.
     Android.Content.Context context = ApplicationContext;
     if (null != context)
     {
         int result = GooglePlayServicesUtil.IsGooglePlayServicesAvailable(context);
         if (ConnectionResult.SUCCESS != result)
         {
             switch (result)
             {
             case ConnectionResult.SERVICE_MISSING:
                 break;
             }
         }
     }
 }
Beispiel #21
0
        /**
         * Show a {@link android.app.Dialog} with the correct message for a connection error.
         *  @param activity the Activity in which the Dialog should be displayed.
         * @param requestCode the request code from onActivityResult.
         * @param actResp the response code from onActivityResult.
         * @param errorDescription the resource id of a String for a generic error message.
         */
        public static void ShowActivityResultError(Activity activity, int requestCode, int actResp, int errorDescription)
        {
            if (activity == null)
            {
                Log.Error("BaseGameUtils", "*** No Activity. Can't show failure dialog!");
                return;
            }
            Dialog errorDialog;

            switch (actResp)
            {
            case GamesActivityResultCodes.ResultAppMisconfigured:
                errorDialog = MakeSimpleDialog(activity,
                                               activity.GetString(Resource.String.app_misconfigured));
                break;

            case GamesActivityResultCodes.ResultSignInFailed:
                errorDialog = MakeSimpleDialog(activity,
                                               activity.GetString(Resource.String.sign_in_failed));
                break;

            case GamesActivityResultCodes.ResultLicenseFailed:
                errorDialog = MakeSimpleDialog(activity,
                                               activity.GetString(Resource.String.license_failed));
                break;

            default:
                // No meaningful Activity response code, so generate default Google
                // Play services dialog
                int errorCode = GooglePlayServicesUtil.IsGooglePlayServicesAvailable(activity);
                errorDialog = GooglePlayServicesUtil.GetErrorDialog(errorCode,
                                                                    activity, requestCode, null);
                if (errorDialog == null)
                {
                    // get fallback dialog
                    Log.Error("BaseGamesUtils",
                              "No standard error dialog available. Making fallback dialog.");
                    errorDialog = MakeSimpleDialog(activity, activity.GetString(errorDescription));
                }
                break;
            }

            errorDialog.Show();
        }
Beispiel #22
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);
        }
        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 #24
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 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);
        }
        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);
        }
Beispiel #27
0
        protected override void OnResume()
        {
            base.OnResume();
            if (!firstCreate)
            {
                circlesFragment.LoadData(this);
            }
            var avail = GooglePlayServicesUtil.IsGooglePlayServicesAvailable(this);

            if (avail == ConnectionResult.Success)
            {
                if (prefs.Enabled)
                {
                    SetTrackingEnabled(true);
                }
                return;
            }
            delayOnBoarding = true;
            GooglePlayServicesUtil.ShowErrorDialogFragment(avail, this, GooglePlayServiceResult, this);
        }
Beispiel #28
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);
        }
        protected void GCMInit()
        {
            try
            {
                PackageInfo pInfo   = this.Activity.PackageManager.GetPackageInfo(this.Activity.PackageName, 0);
                var         shared  = this.Activity.GetSharedPreferences();
                var         version = shared.GetInt(GetString(Resource.String.shared_preferences_version), 0);
                var         temp    = shared.GetString(GetString(Resource.String.shared_preferences_gcm_handle), null);
                if (temp != null)
                {
                    GcmClient.UnRegister(Activity);
                }
                // If already registered for GCM, or if not connected to the internet proceed to login
                if (isNetworkAvailable())
                {
                    // Check for Google GCM
                    int errorCode = GooglePlayServicesUtil.IsGooglePlayServicesAvailable(this.Activity);
                    if (errorCode == ConnectionResult.Success)
                    {
                        GcmClient.Register(this.Activity, GcmBroadcastReceiver.SENDER_IDS);
                        Insight.Track("GcmClient.Register");
                    }
                    else
                    {
                        const int          PLAY_SERVICES_RESOLUTION_REQUEST = 9000;
                        Android.App.Dialog dialog = GooglePlayServicesUtil.GetErrorDialog(errorCode, this.Activity, PLAY_SERVICES_RESOLUTION_REQUEST);
                        dialog.DismissEvent += delegate
                        {
                            this.Activity.Finish();
                        };

                        dialog.Show();
                    }
                }
            }
            catch (Exception e)
            {
                Insight.Report(e);
            }
        }
        /// <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);
            }
        }