Search in sources :

Example 11 with GoogleSignInResult

use of com.google.android.gms.auth.api.signin.GoogleSignInResult in project YourAppIdea by Michenux.

the class GoogleAuthDelegate method onActivityResult.

public void onActivityResult(int requestCode, int resultCode, Intent data) {
    // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
    if (requestCode == RC_SIGN_IN) {
        GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
        handleSignInResult(result);
    }
}
Also used : GoogleSignInResult(com.google.android.gms.auth.api.signin.GoogleSignInResult)

Example 12 with GoogleSignInResult

use of com.google.android.gms.auth.api.signin.GoogleSignInResult in project easy by MehdiBenmesa.

the class RestApiActivity method onActivityResult.

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
    if (requestCode == RC_SIGN_IN) {
        GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
        handleSignInResult(result);
    }
    // Handling a user-recoverable auth exception
    if (requestCode == RC_RECOVERABLE) {
        if (resultCode == RESULT_OK) {
            getContacts();
        } else {
            Toast.makeText(this, R.string.msg_contacts_failed, Toast.LENGTH_SHORT).show();
        }
    }
}
Also used : GoogleSignInResult(com.google.android.gms.auth.api.signin.GoogleSignInResult)

Example 13 with GoogleSignInResult

use of com.google.android.gms.auth.api.signin.GoogleSignInResult in project easy by MehdiBenmesa.

the class RestApiActivity method onStart.

@Override
public void onStart() {
    super.onStart();
    OptionalPendingResult<GoogleSignInResult> opr = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
    if (opr.isDone()) {
        // If the user's cached credentials are valid, the OptionalPendingResult will be "done"
        // and the GoogleSignInResult will be available instantly.
        Log.d(TAG, "Got cached sign-in");
        GoogleSignInResult result = opr.get();
        handleSignInResult(result);
    } else {
        // If the user has not previously signed in on this device or the sign-in has expired,
        // this asynchronous branch will attempt to sign in the user silently.  Cross-device
        // single sign-on will occur in this branch.
        showProgressDialog();
        opr.setResultCallback(new ResultCallback<GoogleSignInResult>() {

            @Override
            public void onResult(GoogleSignInResult googleSignInResult) {
                hideProgressDialog();
                handleSignInResult(googleSignInResult);
            }
        });
    }
}
Also used : GoogleSignInResult(com.google.android.gms.auth.api.signin.GoogleSignInResult)

Example 14 with GoogleSignInResult

use of com.google.android.gms.auth.api.signin.GoogleSignInResult in project easy by MehdiBenmesa.

the class StartActivity method onStart.

@Override
public void onStart() {
    super.onStart();
    OptionalPendingResult<GoogleSignInResult> opr = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
    if (opr.isDone()) {
        // If the user's cached credentials are valid, the OptionalPendingResult will be "done"
        // and the GoogleSignInResult will be available instantly.
        Log.d(TAG, "Got cached sign-in");
        GoogleSignInResult result = opr.get();
        handleSignInResult(result);
    } else {
        // If the user has not previously signed in on this device or the sign-in has expired,
        // this asynchronous branch will attempt to sign in the user silently.  Cross-device
        // single sign-on will occur in this branch.
        showProgressDialog();
        opr.setResultCallback(new ResultCallback<GoogleSignInResult>() {

            @Override
            public void onResult(GoogleSignInResult googleSignInResult) {
                hideProgressDialog();
                handleSignInResult(googleSignInResult);
            }
        });
    }
}
Also used : GoogleSignInResult(com.google.android.gms.auth.api.signin.GoogleSignInResult)

Example 15 with GoogleSignInResult

use of com.google.android.gms.auth.api.signin.GoogleSignInResult in project RSAndroidApp by RailwayStations.

the class SignInActivity method onActivityResult.

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
    if (requestCode == RC_SIGN_IN) {
        GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
        if (result.isSuccess()) {
            // Google Sign In was successful, authenticate with Firebase
            GoogleSignInAccount account = result.getSignInAccount();
            firebaseAuthWithGoogle(account);
        } else {
            // Google Sign In failed
            Log.e(TAG, "Google Sign In failed.");
        }
    }
}
Also used : GoogleSignInAccount(com.google.android.gms.auth.api.signin.GoogleSignInAccount) GoogleSignInResult(com.google.android.gms.auth.api.signin.GoogleSignInResult)

Aggregations

GoogleSignInResult (com.google.android.gms.auth.api.signin.GoogleSignInResult)28 GoogleSignInAccount (com.google.android.gms.auth.api.signin.GoogleSignInAccount)5 ConnectionResult (com.google.android.gms.common.ConnectionResult)1 GoogleApiClient (com.google.android.gms.common.api.GoogleApiClient)1