Code example for ConnectionResult

Methods: getErrorCodehasResolutionstartResolutionForResult

0
     * necessary for sign-in to work. 
     */ 
    void resolveConnectionResult() { 
        // Try to resolve the problem 
        debugLog("resolveConnectionResult: trying to resolve result: " + mConnectionResult);
        if (mConnectionResult.hasResolution()) {
            // This problem can be fixed. So let's try to fix it. 
            debugLog("result has resolution. Starting it."); 
            try { 
                // launch appropriate UI flow (which might, for example, be the 
                // sign-in flow) 
                mExpectingActivityResult = true;
                mConnectionResult.startResolutionForResult(mActivity, RC_RESOLVE);
            } catch (SendIntentException e) {
                // Try connecting again 
                debugLog("SendIntentException."); 
                connectCurrentClient(); 
            } 
        } else { 
            // It's not a problem what we can solve, so give up and show an 
            // error. 
            debugLog("resolveConnectionResult: result has no resolution. Giving up."); 
            giveUp(); 
        } 
    } 
 
    /** 
     * Give up on signing in due to an error. Shows the appropriate error 
     * message to the user, using a standard error dialog as appropriate to the 
     * cause of the error. That dialog will indicate to the user how the problem 
     * can be solved (for example, re-enable Google Play Services, upgrade to a 
     * new version, etc). 
     */ 
    void giveUp() { 
        mSignInError = true;
        mAutoSignIn = false;
        dismissDialog(); 
        debugLog("giveUp: giving up on connection. " + 
                ((mConnectionResult == null) ? "(no connection result)" :
                        ("Status code: " + mConnectionResult.getErrorCode())));
 
        Dialog errorDialog = null;
        if (mConnectionResult != null) {
            // get error dialog for that specific problem 
            errorDialog = getErrorDialog(mConnectionResult.getErrorCode());
            errorDialog.show();
            if (mListener != null) {
                mListener.onSignInFailed();
            } 
        } else {