com.google.example.games.basegameutils.BaseGameUtils Java Examples

The following examples show how to use com.google.example.games.basegameutils.BaseGameUtils. 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: PlayActivity.java    From FixMath with Apache License 2.0 6 votes vote down vote up
protected void onActivityResult(int requestCode, int resultCode,
                                Intent intent) {
    if (requestCode == RC_SIGN_IN) {
        mSignInClicked = false;
        mResolvingConnectionFailure = false;
        if (resultCode == RESULT_OK) {
            googleApiClient.connect();
        } else {
            // Bring up an error dialog to alert the user that sign-in
            // failed. The R.string.signin_failure should reference an error
            // string in your strings.xml file that tells the user they
            // could not be signed in, such as "Unable to sign in."
            BaseGameUtils.showActivityResultError(this,
                    requestCode, resultCode, R.string.signin_failure);

            SharedPreferences scorePref = getSharedPreferences("LOGGING", MODE_PRIVATE);
            SharedPreferences.Editor editor = scorePref.edit();
            editor.putBoolean("SIGN_STATUS", false);
            editor.commit();


        }
    }


}
 
Example #2
Source File: MenuActivity.java    From FixMath with Apache License 2.0 6 votes vote down vote up
protected void onActivityResult(int requestCode, int resultCode,
                                Intent intent) {
    if (requestCode == RC_SIGN_IN) {
        mSignInClicked = false;
        mResolvingConnectionFailure = false;
        if (resultCode == RESULT_OK) {
            mGoogleApiClient.connect();
        } else {
            // Bring up an error dialog to alert the user that sign-in
            // failed. The R.string.signin_failure should reference an error
            // string in your strings.xml file that tells the user they
            // could not be signed in, such as "Unable to sign in."
            BaseGameUtils.showActivityResultError(this,
                    requestCode, resultCode, R.string.signin_failure);

            SharedPreferences scorePref = getSharedPreferences("LOGGING", MODE_PRIVATE);
            SharedPreferences.Editor editor = scorePref.edit();
            editor.putBoolean("SIGN_STATUS", false);
            editor.commit();


        }
    }


}
 
Example #3
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 #4
Source File: SettingsActivity.java    From FixMath with Apache License 2.0 6 votes vote down vote up
protected void onActivityResult(int requestCode, int resultCode,
                                Intent intent) {
    if (requestCode == RC_SIGN_IN) {
        mSignInClicked = false;
        mResolvingConnectionFailure = false;
        if (resultCode == RESULT_OK) {
            mGoogleApi.connect();
        } else {
            // Bring up an error dialog to alert the user that sign-in
            // failed. The R.string.signin_failure should reference an error
            // string in your strings.xml file that tells the user they
            // could not be signed in, such as "Unable to sign in."
            BaseGameUtils.showActivityResultError(this,
                    requestCode, resultCode, R.string.signin_failure);

            SharedPreferences scorePref = getSharedPreferences("LOGGING", MODE_PRIVATE);
            SharedPreferences.Editor editor = scorePref.edit();
            editor.putBoolean("SIGN_STATUS", false);
            editor.commit();

        }
    }

}
 
Example #5
Source File: TimeAttackActivity.java    From FixMath with Apache License 2.0 6 votes vote down vote up
protected void onActivityResult(int requestCode, int resultCode,
                                Intent intent) {
    if (requestCode == RC_SIGN_IN) {
        mSignInClicked = false;
        mResolvingConnectionFailure = false;
        if (resultCode == RESULT_OK) {
            mGoogleApiClient.connect();
        } else {
            // Bring up an error dialog to alert the user that sign-in
            // failed. The R.string.signin_failure should reference an error
            // string in your strings.xml file that tells the user they
            // could not be signed in, such as "Unable to sign in."
            BaseGameUtils.showActivityResultError(this,
                    requestCode, resultCode, R.string.signin_failure);

            SharedPreferences scorePref = getSharedPreferences("LOGGING", MODE_PRIVATE);
            SharedPreferences.Editor editor = scorePref.edit();
            editor.putBoolean("SIGN_STATUS", false);
            editor.commit();


        }
    }


}
 
Example #6
Source File: ChooseTimeChallenge.java    From FixMath with Apache License 2.0 6 votes vote down vote up
protected void onActivityResult(int requestCode, int resultCode,
                                Intent intent) {
    if (requestCode == RC_SIGN_IN) {
        mSignInClicked = false;
        mResolvingConnectionFailure = false;
        if (resultCode == RESULT_OK) {
            mGoogleApiClient.connect();
        } else {
            // Bring up an error dialog to alert the user that sign-in
            // failed. The R.string.signin_failure should reference an error
            // string in your strings.xml file that tells the user they
            // could not be signed in, such as "Unable to sign in."
            BaseGameUtils.showActivityResultError(this,
                    requestCode, resultCode, R.string.signin_failure);

            SharedPreferences scorePref = getSharedPreferences("LOGGING", MODE_PRIVATE);
            SharedPreferences.Editor editor = scorePref.edit();
            editor.putBoolean("SIGN_STATUS", false);
            editor.commit();


        }
    }


}
 
Example #7
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 #8
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 #9
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 #10
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 #11
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 #12
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 #13
Source File: BaseGooglePlayServicesActivity.java    From Onesearch with MIT License 5 votes vote down vote up
protected void onActivityResult(int requestCode, int resultCode,
                                Intent intent) {
    if (requestCode == RC_SIGN_IN) {
        mSignInClicked = false;
        mResolvingConnectionFailure = false;
        if (resultCode == RESULT_OK) {
            mGoogleApiClient.connect();
        } else {
            BaseGameUtils.showActivityResultError(this,
                    requestCode, resultCode, R.string.sign_in_failed);
        }
    }
}
 
Example #14
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();
}