Java Code Examples for com.google.android.gms.auth.api.Auth

The following examples show how to use com.google.android.gms.auth.api.Auth. These examples are extracted from open source projects. 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 Project: identity-samples   Source File: PhoneNumberActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_phone_number);
    ui = new PhoneNumberUi(findViewById(R.id.phone_number), getActivityTitle());

    String defaultPhone = getPrefs().getPhoneNumber(null);
    if (defaultPhone != null) {
        ui.setPhoneNumber(defaultPhone);
    }

    mCredentialsApiClient = new GoogleApiClient.Builder(this)
            .addConnectionCallbacks(this)
            .enableAutoManage(this, this)
            .addApi(Auth.CREDENTIALS_API)
            .build();
}
 
Example 2
Source Project: identity-samples   Source File: PhoneNumberActivity.java    License: Apache License 2.0 6 votes vote down vote up
private void showHint() {
    ui.clearKeyboard();
    HintRequest hintRequest = new HintRequest.Builder()
            .setHintPickerConfig(new CredentialPickerConfig.Builder()
                    .setShowCancelButton(true)
                    .build())
            .setPhoneNumberIdentifierSupported(true)
            .build();

    PendingIntent intent =
            Auth.CredentialsApi.getHintPickerIntent(mCredentialsApiClient, hintRequest);
    try {
        startIntentSenderForResult(intent.getIntentSender(), RC_HINT, null, 0, 0, 0);
    } catch (IntentSender.SendIntentException e) {
        Log.e(TAG, "Could not start hint picker Intent", e);
    }
}
 
Example 3
Source Project: PGSGP   Source File: PlayGameServices.java    License: MIT License 6 votes vote down vote up
protected void onMainActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == SignInController.RC_SIGN_IN) {
        GoogleSignInResult googleSignInResult = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
        signInController.onSignInActivityResult(googleSignInResult);
    } else if (requestCode == AchievementsController.RC_ACHIEVEMENT_UI || requestCode == LeaderboardsController.RC_LEADERBOARD_UI) {
        Pair<Boolean, String> isConnected = connectionController.isConnected();
        godotCallbacksUtils.invokeGodotCallback(GodotCallbacksUtils.PLAYER_CONNECTED, new Object[]{isConnected.first, isConnected.second});
    } else if (requestCode == SavedGamesController.RC_SAVED_GAMES) {
        if (data != null) {
            if (data.hasExtra(SnapshotsClient.EXTRA_SNAPSHOT_METADATA)) {
                SnapshotMetadata snapshotMetadata = data.getParcelableExtra(SnapshotsClient.EXTRA_SNAPSHOT_METADATA);
                if (snapshotMetadata != null) {
                    savedGamesController.loadSnapshot(snapshotMetadata.getUniqueName());
                }
            } else if (data.hasExtra(SnapshotsClient.EXTRA_SNAPSHOT_NEW)) {
                String unique = new BigInteger(281, new Random()).toString(13);
                String currentSaveName = appActivity.getString(R.string.default_game_name) + unique;

                savedGamesController.createNewSnapshot(currentSaveName);
            }
        }
    }
}
 
Example 4
Source Project: react-native-sms-retriever   Source File: PhoneNumberHelper.java    License: MIT License 6 votes vote down vote up
@NonNull
private GoogleApiClient getGoogleApiClient(@NonNull final Context context, final Activity activity) {
    if (mGoogleApiClient == null) {
        GoogleApiClient.Builder builder = new GoogleApiClient.Builder(context);
        builder = builder.addConnectionCallbacks(mApiClientConnectionCallbacks);
        builder = builder.addApi(Auth.CREDENTIALS_API);

        if (activity instanceof FragmentActivity) {
            final FragmentActivity fragmentActivity = (FragmentActivity) activity;
            builder = builder.enableAutoManage(fragmentActivity, mApiClientOnConnectionFailedListener);
        }

        mGoogleApiClient = builder.build();
    }

    return mGoogleApiClient;
}
 
Example 5
Source Project: social-app-android   Source File: GoogleApiHelper.java    License: Apache License 2.0 6 votes vote down vote up
public static GoogleApiClient createGoogleApiClient(FragmentActivity fragmentActivity) {
    GoogleApiClient.OnConnectionFailedListener failedListener;

    if (fragmentActivity instanceof GoogleApiClient.OnConnectionFailedListener) {
        failedListener = (GoogleApiClient.OnConnectionFailedListener) fragmentActivity;
    } else {
        throw new IllegalArgumentException(fragmentActivity.getClass().getSimpleName() + " should implement OnConnectionFailedListener");
    }

    GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestIdToken(fragmentActivity.getResources().getString(R.string.google_web_client_id))
            .requestEmail()
            .build();

    return new GoogleApiClient.Builder(fragmentActivity)
            .enableAutoManage(fragmentActivity, failedListener)
            .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
            .build();
}
 
Example 6
Source Project: UberClone   Source File: DriverHome.java    License: MIT License 6 votes vote down vote up
private void verifyGoogleAccount() {
    GoogleSignInOptions gso=new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN).requestEmail().build();
    mGoogleApiClient=new GoogleApiClient.Builder(this)
            .enableAutoManage(this, this)
            .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
            .build();
    OptionalPendingResult<GoogleSignInResult> opr=Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
    if (opr.isDone()){
        GoogleSignInResult result= opr.get();
        handleSignInResult(result);
    }else {
        opr.setResultCallback(new ResultCallback<GoogleSignInResult>() {
            @Override
            public void onResult(@NonNull GoogleSignInResult googleSignInResult) {
                handleSignInResult(googleSignInResult);
            }
        });
    }
}
 
Example 7
Source Project: UberClone   Source File: DriverTracking.java    License: MIT License 6 votes vote down vote up
private void verifyGoogleAccount() {
    GoogleSignInOptions gso=new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN).requestEmail().build();
    mGoogleApiClient=new GoogleApiClient.Builder(this)
            .enableAutoManage(this, this)
            .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
            .build();
    OptionalPendingResult<GoogleSignInResult> opr=Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
    if (opr.isDone()){
        GoogleSignInResult result= opr.get();
        handleSignInResult(result);
    }else {
        opr.setResultCallback(new ResultCallback<GoogleSignInResult>() {
            @Override
            public void onResult(@NonNull GoogleSignInResult googleSignInResult) {
                handleSignInResult(googleSignInResult);
            }
        });
    }
}
 
Example 8
Source Project: UberClone   Source File: Home.java    License: MIT License 6 votes vote down vote up
private void verifyGoogleAccount() {
    GoogleSignInOptions gso=new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN).requestEmail().build();
    mGoogleApiClient=new GoogleApiClient.Builder(this)
            .enableAutoManage(this, this)
            .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
            .build();
    OptionalPendingResult<GoogleSignInResult> opr=Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
    if (opr.isDone()){
        GoogleSignInResult result= opr.get();
        handleSignInResult(result);
    }else {
        opr.setResultCallback(new ResultCallback<GoogleSignInResult>() {
            @Override
            public void onResult(@NonNull GoogleSignInResult googleSignInResult) {
                handleSignInResult(googleSignInResult);
            }
        });
    }
}
 
Example 9
Source Project: socialmediasignup   Source File: GoogleSignUpActivity.java    License: MIT License 6 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    String clientId = SocialMediaSignUpUtils.getMetaDataValue(this, getString(R.string.com_ahmedadel_socialmediasignup_googleWebClientId));

    GoogleSignInOptions.Builder gsoBuilder = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestId()
            .requestProfile()
            .requestEmail()
            .requestIdToken(clientId);

    setupScopes(gsoBuilder);

    googleApiClient = new GoogleApiClient.Builder(this)
            .enableAutoManage(this, this)
            .addConnectionCallbacks(this)
            .addApi(Auth.GOOGLE_SIGN_IN_API, gsoBuilder.build())
            .build();
}
 
Example 10
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
    if (requestCode == GOOGLE_SIGN_IN_CODE) {
        GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
        if (result == null) return;

        if (result.isSuccess()) {
            googleSignedIn(result.getSignInAccount());
        } else {
            if (result.getStatus().getStatusCode() == GoogleSignInStatusCodes.SIGN_IN_CANCELLED)
                Prefs.putBoolean(PK.SHOULD_PROMPT_GOOGLE_PLAY, false);

            String msg = result.getStatus().getStatusMessage();
            if (msg != null && !msg.isEmpty())
                Toaster.with(this).message(msg).show();
        }
    } else {
        super.onActivityResult(requestCode, resultCode, data);
    }
}
 
Example 11
@Override
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
    if (requestCode == GOOGLE_SIGN_IN_CODE) {
        GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
        if (result == null) return;

        if (result.isSuccess()) {
            onBackPressed();
        } else {
            String msg = result.getStatus().getStatusMessage();
            if (msg != null && !msg.isEmpty())
                showToast(Toaster.build().message(msg));
        }
    } else {
        super.onActivityResult(requestCode, resultCode, data);
    }
}
 
Example 12
Source Project: EasyLogin   Source File: GooglePlusNetwork.java    License: MIT License 6 votes vote down vote up
public GooglePlusNetwork(Activity activity) {

        sharedPrefs = activity.getSharedPreferences(SHARED_PREFS_NAME, Context.MODE_PRIVATE);

        this.activity = new WeakReference<>(activity);
        GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                .requestEmail()
                .build();

        GoogleApiClient.Builder googleApiBuilder = new GoogleApiClient.Builder(activity);
        if (activity instanceof FragmentActivity) {
            googleApiBuilder.enableAutoManage((FragmentActivity) activity, this);
        } else {
            googleApiBuilder
                    .addConnectionCallbacks(this)
                    .addOnConnectionFailedListener(this);
        }
        googleApiClient = googleApiBuilder
                .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
                .build();
    }
 
Example 13
Source Project: friendlypix-android   Source File: ProfileActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onClick(View v) {
    int id = v.getId();
    switch(id) {
        case R.id.launch_sign_in:
            launchSignInIntent();
            break;
        case R.id.sign_out_button:
            mAuth.signOut();
            Auth.GoogleSignInApi.signOut(mGoogleApiClient);
            showSignedOutUI();
            break;
        case R.id.show_feeds_button:
            Intent feedsIntent = new Intent(this, FeedsActivity.class);
            startActivity(feedsIntent);
            break;
    }
}
 
Example 14
Source Project: RxSocialAuth   Source File: RxGoogleAuthFragment.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Handle google sign in result
 *
 * @param result the GoogleSignInResult result
 */
public void handleSignInResult(final GoogleSignInResult result) {
    if (result.isSuccess()) {
        GoogleSignInAccount account = result.getSignInAccount();
        mGoogleApiClient.disconnect();
        verifySmartLockIsEnabled(new RxAccount(account));
    }
    else {
        // delete credential
        if(mCredential != null) {
            Auth.CredentialsApi.delete(mGoogleApiClient, mCredential).setResultCallback(new ResultCallback<Status>() {
                @Override
                public void onResult(@NonNull Status status) {
                    mGoogleApiClient.disconnect();
                    mAccountSubject.onError(new Throwable(result.getStatus().toString()));
                }
            });
        }
        else {
            mGoogleApiClient.disconnect();
            mAccountSubject.onError(new Throwable(result.getStatus().toString()));
        }
    }
}
 
Example 15
Source Project: FeedFire   Source File: GoogleSign.java    License: MIT License 6 votes vote down vote up
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);
        if (result.isSuccess()) {
            // Google Sign In was successful, authenticate with Firebase
            GoogleSignInAccount account = result.getSignInAccount();
            firebaseAuthWithGoogle(account);
        } else {
            // Google Sign In failed, update UI appropriately
            // [START_EXCLUDE]
            mGoogleCallback.loginFailed();
            // [END_EXCLUDE]
        }
    }
}
 
Example 16
Source Project: FChat   Source File: SplashActivity.java    License: MIT License 6 votes vote down vote up
@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()) {
            signInButton.setVisibility(View.GONE);
            loginProgress.setVisibility(View.VISIBLE);
            // Google Sign In was successful, authenticate with Firebase
            GoogleSignInAccount account = result.getSignInAccount();
            firebaseAuthWithGoogle(account);
        } else {
            customToast.showError(getString(R.string.error_login_failed));
        }
    }
}
 
Example 17
Source Project: Expert-Android-Programming   Source File: SignInBaseActivity.java    License: MIT License 6 votes vote down vote up
@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 {
        callbackManager.onActivityResult(requestCode, resultCode, data);
    }
}
 
Example 18
Source Project: RxSocialAuth   Source File: RxSmartLockPasswordsFragment.java    License: Apache License 2.0 6 votes vote down vote up
private void requestCredentialAndAutoSignIn() {
    // disable auto sign in
    if(mDisableAutoSignIn)
        Auth.CredentialsApi.disableAutoSignIn(mCredentialsApiClient);

    Auth.CredentialsApi.request(mCredentialsApiClient, mCredentialRequest).setResultCallback(
            new ResultCallback<CredentialRequestResult>() {
                @Override
                public void onResult(@NonNull CredentialRequestResult credentialRequestResult) {
                    if(credentialRequestResult.getStatus().isSuccess())
                        onCredentialRetrieved(credentialRequestResult.getCredential());
                    else
                        resolveResult(credentialRequestResult.getStatus());
                }
            });
}
 
Example 19
Source Project: security-samples   Source File: Fido2DemoActivity.java    License: Apache License 2.0 5 votes vote down vote up
private void signOut() {
    Auth.GoogleSignInApi.signOut(googleApiClient)
            .setResultCallback(
                    new ResultCallback<Status>() {
                        @Override
                        public void onResult(@NonNull Status status) {
                            clearAccountSignInStatus();
                            updateUI();
                            gaeService = null;
                        }
                    });
}
 
Example 20
Source Project: andela-med-manager   Source File: MainActivity.java    License: Apache License 2.0 5 votes vote down vote up
private void logout() {
    if (!Settings.isLoggedIn()) {
        return;
    }

    SnackProgressBar snackProgressBar = new SnackProgressBar(
            SnackProgressBar.TYPE_INDETERMINATE,
            "Logging Out...")
            .setSwipeToDismiss(false);

    // Show snack progress during logout
    snackProgressBarManager.dismissAll();
    snackProgressBarManager.show(snackProgressBar, SnackProgressBarManager.LENGTH_INDEFINITE);

    Auth.GoogleSignInApi.signOut(mGoogleApiClient).setResultCallback(status -> {
        //Clear Shared Pref File
        Settings.setLoggedInSharedPref(false);
        //Clear Local DB
        //TODO :: CLEAR DB

        //Redirect User to Login Page
        Intent intent = new Intent(getApplicationContext(), AuthActivity.class);
        startActivity(intent);
        finish();
    });

    //Unreachable anyway
    snackProgressBarManager.dismiss();
}
 
Example 21
Source Project: andela-med-manager   Source File: AuthActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_auth);
    ButterKnife.bind(this);

    addUserViewModel = ViewModelProviders.of(this).get(AddUserViewModel.class);

    GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestEmail()
            .build();

    // Build a GoogleApiClient with access to the Google Sign-In Api and the
    // options specified by gso.
    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .enableAutoManage(this /* FragmentActivitgit y */, this /* OnConnectionFailedListener */)
            .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
            .build();

    loginButton.setOnClickListener(v -> {
        //Check Internet Connection
        //  if (NetworkUtil.isConnected(this))
        googleSignIn();

    });
}
 
Example 22
Source Project: andela-med-manager   Source File: AuthActivity.java    License: Apache License 2.0 5 votes vote down vote up
@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);
    }
}
 
Example 23
Source Project: social-app-android   Source File: LoginActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    mCallbackManager.onActivityResult(requestCode, resultCode, data);
    // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
    if (requestCode == SIGN_IN_GOOGLE) {
        GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
        presenter.handleGoogleSignInResult(result);
    }
}
 
Example 24
Source Project: social-app-android   Source File: LogoutHelper.java    License: Apache License 2.0 5 votes vote down vote up
private static void logoutGoogle(GoogleApiClient mGoogleApiClient, FragmentActivity fragmentActivity) {
    if (mGoogleApiClient == null) {
        mGoogleApiClient = GoogleApiHelper.createGoogleApiClient(fragmentActivity);
    }

    if (!mGoogleApiClient.isConnected()) {
        mGoogleApiClient.connect();
    }

    final GoogleApiClient finalMGoogleApiClient = mGoogleApiClient;
    mGoogleApiClient.registerConnectionCallbacks(new GoogleApiClient.ConnectionCallbacks() {
        @Override
        public void onConnected(@Nullable Bundle bundle) {
            if (finalMGoogleApiClient.isConnected()) {
                Auth.GoogleSignInApi.signOut(finalMGoogleApiClient).setResultCallback(new ResultCallback<Status>() {
                    @Override
                    public void onResult(@NonNull Status status) {
                        if (status.isSuccess()) {
                            LogUtil.logDebug(TAG, "User Logged out from Google");
                        } else {
                            LogUtil.logDebug(TAG, "Error Logged out from Google");
                        }
                    }
                });
            }
        }

        @Override
        public void onConnectionSuspended(int i) {
            LogUtil.logDebug(TAG, "Google API Client Connection Suspended");
        }
    });
}
 
Example 25
Source Project: UberClone   Source File: Login.java    License: MIT License 5 votes vote down vote up
private void verifyGoogleAccount() {
    OptionalPendingResult<GoogleSignInResult> opr= Auth.GoogleSignInApi.silentSignIn(googleApiClient);
    if (opr.isDone()){
        GoogleSignInResult result= opr.get();
        if (result.isSuccess())
            firebaseHelper.loginSuccess();

    }
}
 
Example 26
Source Project: UberClone   Source File: Login.java    License: MIT License 5 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode==SIGN_IN_CODE_GOOGLE) {//Google
        GoogleSignInResult result=Auth.GoogleSignInApi.getSignInResultFromIntent(data);
        handleSignInResult(result);
    }
    mFacebookCallbackManager.onActivityResult(requestCode, resultCode, data);
}
 
Example 27
Source Project: Simple-Blog-App   Source File: LoginActivity.java    License: MIT License 5 votes vote down vote up
private void googleInit() {
    GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestIdToken(getString(R.string.default_web_client_id))
            .requestEmail()
            .build();
    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */)
            .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
            .build();
}
 
Example 28
Source Project: RxSocialAuth   Source File: RxGoogleAuthFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == RC_SIGN_IN) {
        GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
        handleSignInResult(result);
    }
}
 
Example 29
Source Project: EasyLogin   Source File: GooglePlusNetwork.java    License: MIT License 5 votes vote down vote up
public void silentSignIn() {
    OptionalPendingResult<GoogleSignInResult> pendingResult =
            Auth.GoogleSignInApi.silentSignIn(googleApiClient);
    if (pendingResult.isDone()) {
        // There's immediate result available.
        parseGoogleSignInResult(pendingResult.get());
    } else {
        pendingResult.setResultCallback(new ResultCallback<GoogleSignInResult>() {
            @Override
            public void onResult(@NonNull GoogleSignInResult result) {
                parseGoogleSignInResult(result);
            }
        });
    }
}
 
Example 30
Source Project: EasyLogin   Source File: GooglePlusNetwork.java    License: MIT License 5 votes vote down vote up
@Override
public void logout() {
    if (isConnected()) {
        Auth.GoogleSignInApi.signOut(googleApiClient);
        googleApiClient.disconnect();
        setSignInButtonEnabled(true);
        sharedPrefs.edit().putBoolean(GPLUS_CONNECTED, false).apply();
    }
}