Пример #1
0
        public void OnConnectionSuspended(int i)
        {
            Log("onConnectionSuspended: " + i);

            UpdateViewVisibility(NearbyConnectionState.Idle);

            // Try to re-connect
            mGoogleApiClient.Reconnect();
        }
        protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            logVerbose(String.Format("onActivityResult - requestCode:{0} resultCode:{1}", requestCode,
                                     resultCode));

            if (requestCode == REQUEST_CODE_SIGN_IN ||
                requestCode == REQUEST_CODE_GET_GOOGLE_PLAY_SERVICES)
            {
                mIntentInProgress = false; //Previous resolution intent no longer in progress.

                if (resultCode == Result.Ok)
                {
                    // After resolving a recoverable error, now retry connect(). Note that it's possible
                    // mGoogleApiClient is already connected or connecting due to rotation / Activity
                    // restart while user is walking through the (possibly full screen) resolution
                    // Activities. We should always reconnect() and ignore earlier connection attempts
                    // started before completion of the resolution. (With only one exception, a
                    // connect() attempt started late enough in the resolution flow and it actually
                    // succeeded)
                    if (!mGoogleApiClient.IsConnected)
                    {
                        logVerbose("Previous resolution completed successfully, try connecting again");
                        mGoogleApiClient.Reconnect();
                    }
                }
                else
                {
                    mSignInClicked = false; // No longer in the middle of resolving sign-in errors.

                    if (resultCode == Result.Canceled)
                    {
                        mSignInStatus.Text = GetString(Resource.String.signed_out_status);
                    }
                    else
                    {
                        mSignInStatus.Text = GetString(Resource.String.sign_in_error_status);
                        Console.WriteLine("Error during resolving recoverable error.");
                    }
                }
            }
        }