Java Code Examples for com.google.example.games.basegameutils.BaseGameUtils#resolveConnectionFailure()

The following examples show how to use com.google.example.games.basegameutils.BaseGameUtils#resolveConnectionFailure() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SettingsActivity.java    From FixMath with Apache License 2.0 6 votes vote down vote up
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
    if (mResolvingConnectionFailure) {
        // Already resolving
        return;
    }

    // If the sign in button was clicked or if auto sign-in is enabled,
    // launch the sign-in flow
    if (mSignInClicked || mAutoStartSignInFlow) {
        mAutoStartSignInFlow = false;
        mSignInClicked = false;
        mResolvingConnectionFailure = true;

        // Attempt to resolve the connection failure using BaseGameUtils.
        // The R.string.signin_other_error value should reference a generic
        // error string in your strings.xml file, such as "There was
        // an issue with sign in, please try again later."
        if (!BaseGameUtils.resolveConnectionFailure(this,
                mGoogleApi, connectionResult,
                RC_SIGN_IN, getString(R.string.signin_other_error))) {
            mResolvingConnectionFailure = false;
        }
    }

}
 
Example 2
Source File: MainActivity.java    From Asteroid with Apache License 2.0 5 votes vote down vote up
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
    achievementsView.setVisibility(View.GONE);
    rankView.setVisibility(View.GONE);
    gamesView.setVisibility(View.GONE);
    BaseGameUtils.resolveConnectionFailure(this, apiClient, connectionResult, 1801, R.string.msg_sign_in_error);
}
 
Example 3
Source File: PlayActivity.java    From FixMath with Apache License 2.0 5 votes vote down vote up
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
    if (mResolvingConnectionFailure) {
        // Already resolving
        return;
    }

    // If the sign in button was clicked or if auto sign-in is enabled,
    // launch the sign-in flow
    if (mSignInClicked || mAutoStartSignInFlow) {
        mAutoStartSignInFlow = false;
        mSignInClicked = false;
        mResolvingConnectionFailure = true;

        // Attempt to resolve the connection failure using BaseGameUtils.
        // The R.string.signin_other_error value should reference a generic
        // error string in your strings.xml file, such as "There was
        // an issue with sign in, please try again later."
        if (!BaseGameUtils.resolveConnectionFailure(this,
                googleApiClient, connectionResult,
                RC_SIGN_IN, getString(R.string.signin_other_error))) {
            mResolvingConnectionFailure = false;
        }
    }




}
 
Example 4
Source File: MenuActivity.java    From FixMath with Apache License 2.0 5 votes vote down vote up
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
    if (mResolvingConnectionFailure) {
        // Already resolving
        return;
    }

    // If the sign in button was clicked or if auto sign-in is enabled,
    // launch the sign-in flow
    if (mSignInClicked || mAutoStartSignInFlow) {
        mAutoStartSignInFlow = false;
        mSignInClicked = false;
        mResolvingConnectionFailure = true;

        // Attempt to resolve the connection failure using BaseGameUtils.
        // The R.string.signin_other_error value should reference a generic
        // error string in your strings.xml file, such as "There was
        // an issue with sign in, please try again later."
        if (!BaseGameUtils.resolveConnectionFailure(this,
                mGoogleApiClient, connectionResult,
                RC_SIGN_IN, getString(R.string.signin_other_error))) {
            mResolvingConnectionFailure = false;
        }
    }


    googlePlayBtn.setVisibility(View.VISIBLE);

}
 
Example 5
Source File: TimeAttackActivity.java    From FixMath with Apache License 2.0 5 votes vote down vote up
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
    if (mResolvingConnectionFailure) {
        // Already resolving
        return;
    }

    // If the sign in button was clicked or if auto sign-in is enabled,
    // launch the sign-in flow
    if (mSignInClicked || mAutoStartSignInFlow) {
        mAutoStartSignInFlow = false;
        mSignInClicked = false;
        mResolvingConnectionFailure = true;

        // Attempt to resolve the connection failure using BaseGameUtils.
        // The R.string.signin_other_error value should reference a generic
        // error string in your strings.xml file, such as "There was
        // an issue with sign in, please try again later."
        if (!BaseGameUtils.resolveConnectionFailure(this,
                mGoogleApiClient, connectionResult,
                RC_SIGN_IN, getString(R.string.signin_other_error))) {
            mResolvingConnectionFailure = false;
        }
    }




}
 
Example 6
Source File: ChooseTimeChallenge.java    From FixMath with Apache License 2.0 5 votes vote down vote up
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
    if (mResolvingConnectionFailure) {
        // Already resolving
        return;
    }

    // If the sign in button was clicked or if auto sign-in is enabled,
    // launch the sign-in flow
    if (mSignInClicked || mAutoStartSignInFlow) {
        mAutoStartSignInFlow = false;
        mSignInClicked = false;
        mResolvingConnectionFailure = true;

        // Attempt to resolve the connection failure using BaseGameUtils.
        // The R.string.signin_other_error value should reference a generic
        // error string in your strings.xml file, such as "There was
        // an issue with sign in, please try again later."
        if (!BaseGameUtils.resolveConnectionFailure(this,
                mGoogleApiClient, connectionResult,
                RC_SIGN_IN, getString(R.string.signin_other_error))) {
            mResolvingConnectionFailure = false;
        }
    }




}
 
Example 7
Source File: BaseGooglePlayServicesActivity.java    From Onesearch with MIT License 5 votes vote down vote up
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
    if (mResolvingConnectionFailure) {
        return;
    }

    if (mSignInClicked || mAutoStartSignInflow) {
        mAutoStartSignInflow = false;
        mSignInClicked = false;

        mResolvingConnectionFailure = BaseGameUtils.resolveConnectionFailure(this,
                mGoogleApiClient, connectionResult,
                RC_SIGN_IN, getString(R.string.sign_in_failed));
    }
}
 
Example 8
Source File: GpgsClient.java    From gdx-gamesvcs with Apache License 2.0 4 votes vote down vote up
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
    if (mResolvingConnectionFailure) {
        // already resolving
        return;
    }
    Gdx.app.log(GAMESERVICE_ID, "onConnectFailed: " + connectionResult.getErrorCode());

    boolean isPendingBefore = isConnectionPending;

    // if the sign-in button was clicked
    // launch the sign-in flow
    if (mSignInClicked) {
        mAutoStartSignInflow = false;
        mSignInClicked = false;
        mResolvingConnectionFailure = true;

        // Attempt to resolve the connection failure using BaseGameUtils.
        // The R.string.signin_other_error value should reference a generic
        // error string in your strings.xml file, such as "There was
        // an issue with sign-in, please try again later."
        if (!BaseGameUtils.resolveConnectionFailure(myContext,
                mGoogleApiClient, connectionResult,
                RC_GPGS_SIGNIN, "Unable to sign in.")) {
            mResolvingConnectionFailure = false;
            isConnectionPending = false;
        }
    }
    // Error code 4 is thrown sometimes on first attempt when game state feature is enabled.
    // Just retry some times solves the problem.
    else if (firstConnectAttempt > 0 && connectionResult.getErrorCode() == 4) {
        firstConnectAttempt -= 1;
        Gdx.app.log(GAMESERVICE_ID, "Retrying to connect...");

        AsyncTask<Void, Void, Void> task = new AsyncTask<Void, Void, Void>() {
            @Override
            protected Void doInBackground(Void... params) {
                try {
                    // wait some time before next try
                    Thread.sleep(200);
                    if (!mGoogleApiClient.isConnected())
                        mGoogleApiClient.connect();
                } catch (InterruptedException e) {
                    //eat
                }
                return null;
            }
        };

        task.execute();

    } else
        isConnectionPending = false;

    // inform listener that connection attempt failed
    if (gameListener != null && isPendingBefore && !isConnectionPending)
        gameListener.gsOnSessionInactive();
}