Code example for ConnectionResult

Methods: getErrorCode, hasResolution

0
    } 
     
    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;
                debugLog("Resolving intent with activity "+mParentActivity);
                // create dummy activity 
                /*mDummyActivity = new DummyActivity(); 
                Intent intent = new Intent(); 
                mDummyActivity.startActivity(intent);*/ 
                 
                Intent intent = new Intent(mParentActivity, DummyActivity.class);
    			intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    			//mParentActivity.startActivity(intent); 
    			mParentActivity.startActivityForResult(intent, RC_UNUSED);
    			 
//                mConnectionResult.startResolutionForResult(mParentActivity, RC_RESOLVE); 
                //PendingIntent intent = mConnectionResult.getResolution(); 
//                mParentActivity.startActivityForResult((Intent)intent, RC_RESOLVE); 
            } catch (Exception 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(); 
        } 
    } 
 
     
    void giveUp() { 
        mSignInError = true;
        mAutoSignIn = false;
        debugLog("giveUp: giving up on connection. " + 
                ((mConnectionResult == null) ? "(no connection result)" :
                        ("Status code: " + mConnectionResult.getErrorCode())));
 
        if (mConnectionResult != null) {
            UnitySendMessageSafe("GPGAuthResult", "error,"+mConnectionResult.getErrorCode());
        } else { 
            // this is a bug 
            Log.e("GameHelper", "giveUp() called with no mConnectionResult");
            UnitySendMessageSafe("GPGAuthResult", "error"); 
        }