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

The following examples show how to use com.google.android.gms.auth.api.Auth. 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: ProfileActivity.java    From friendlypix-android with 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 #2
Source File: Home.java    From UberClone with 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 #3
Source File: GoogleSign.java    From FeedFire with 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 #4
Source File: DriverTracking.java    From UberClone with 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 #5
Source File: DriverHome.java    From UberClone with 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 #6
Source File: GoogleSignUpActivity.java    From socialmediasignup with 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 #7
Source File: GoogleApiHelper.java    From social-app-android with 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 #8
Source File: SplashActivity.java    From FChat with 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 #9
Source File: SignInBaseActivity.java    From Expert-Android-Programming with 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 #10
Source File: LoadingActivity.java    From PretendYoureXyzzyAndroid with GNU General Public License v3.0 6 votes vote down vote up
@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
Source File: PreferenceActivity.java    From PretendYoureXyzzyAndroid with GNU General Public License v3.0 6 votes vote down vote up
@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 File: PhoneNumberHelper.java    From react-native-sms-retriever with 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 #13
Source File: PhoneNumberActivity.java    From identity-samples with 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 #14
Source File: PhoneNumberActivity.java    From identity-samples with 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 #15
Source File: PlayGameServices.java    From PGSGP with 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 #16
Source File: RxSmartLockPasswordsFragment.java    From RxSocialAuth with 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 #17
Source File: RxGoogleAuthFragment.java    From RxSocialAuth with 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 #18
Source File: GooglePlusNetwork.java    From EasyLogin with 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 #19
Source File: GoogleHelper.java    From argus-android with Apache License 2.0 5 votes vote down vote up
/**
 * Initializing google api client if no client id provided
 * It will throw null pointer exception while requesting Id token from GoogleSignInAccount
 */
public void initializeGoogleApiClient() {
    GoogleSignInOptions gso = new GoogleSignInOptions.Builder(
            GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestProfile()
            .requestEmail()
            .build();
    googleApiClient = new GoogleApiClient.Builder(fragment.getContext())
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
            .build();
}
 
Example #20
Source File: EasyFirebaseAuth.java    From EasyFirebase with Apache License 2.0 5 votes vote down vote up
public void onActivityResult(int requestCode, Intent data) {
    if (requestCode == RC_SIGN_IN) {
        // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
        GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
        if (result.isSuccess()) {
            // Google Sign In was successful, authenticate with Firebase
            googleSignInAccount = result.getSignInAccount();
            AuthCredential credential = GoogleAuthProvider.getCredential(googleSignInAccount.getIdToken(), null);
            mAuth.signInWithCredential(credential)
                    .addOnCompleteListener(new OnCompleteListener<AuthResult>() {
                        @Override
                        public void onComplete(@NonNull Task<AuthResult> task) {
                            Log.d("TAG", "signInWithCredential:onComplete:" + task.isSuccessful());

                            // If sign in fails, display a message to the user. If sign in succeeds
                            // the auth state listener will be notified and logic to handle the
                            // signed in user can be handled in the listener.
                            if (!task.isSuccessful()) {
                                Log.w("TAG", "signInWithCredential", task.getException());
                            }
                            // ...
                        }
                    });
        } else {
            if (firebaseUserSubscriber != null) {
                firebaseUserSubscriber.onError(new Throwable("error while signing with google"));
            }
            // Google Sign In failed, update UI appropriately
            // ...
        }
    }
}
 
Example #21
Source File: RxGoogleAuthFragment.java    From RxSocialAuth with Apache License 2.0 5 votes vote down vote up
private void signIn() {
    if(mDisableAutoSignIn)
        Auth.GoogleSignInApi.signOut(mGoogleApiClient);

    Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
    //startIntentSenderForResult(signInIntent.get, RC_SIGN_IN, null, 0, 0, 0, null);
    startActivityForResult(signInIntent, RC_SIGN_IN);
}
 
Example #22
Source File: EasyFirebaseAuth.java    From EasyFirebase with Apache License 2.0 5 votes vote down vote up
public Observable<Pair<GoogleSignInAccount, FirebaseUser>> signInWithGoogle(Activity activity) {
    Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(googleApiClient);
    activity.startActivityForResult(signInIntent, RC_SIGN_IN);

    return Observable.create(new Observable.OnSubscribe<Pair<GoogleSignInAccount, FirebaseUser>>() {
        @Override
        public void call(Subscriber<? super Pair<GoogleSignInAccount, FirebaseUser>> s) {
            firebaseUserSubscriber = s;
        }
    });

}
 
Example #23
Source File: ProfileActivity.java    From friendlypix-android with 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);
        handleGoogleSignInResult(result);
    }
}
 
Example #24
Source File: GoogleSignInApi.java    From eternity with Apache License 2.0 5 votes vote down vote up
@Inject
GoogleSignInApi(Application application, StringResolver resolver) {
  client = new GoogleApiClient.Builder(application)
      .addConnectionCallbacks(this)
      .addOnConnectionFailedListener(this)
      .addApi(Auth.GOOGLE_SIGN_IN_API, createGoogleSignInOptions(resolver))
      .build();
}
 
Example #25
Source File: RxSmartLockPasswordsFragment.java    From RxSocialAuth with Apache License 2.0 5 votes vote down vote up
private void requestCredential() {
    // 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) {
                    mCredentialsApiClient.disconnect();
                    mRequestSubject.onNext(credentialRequestResult);
                    mRequestSubject.onCompleted();
                }
            });
}
 
Example #26
Source File: LogoutHelper.java    From social-app-android with 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 #27
Source File: RxSmartLockPasswordsFragment.java    From RxSocialAuth with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mActivity = getActivity();

    // smart lock password
    mCredentialsApiClient = new GoogleApiClient.Builder(mActivity)
            .addConnectionCallbacks(this)
            .addApi(Auth.CREDENTIALS_API)
            .build();
}
 
Example #28
Source File: LoginActivity.java    From social-app-android with 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 #29
Source File: RxSmartLockPasswordsFragment.java    From RxSocialAuth with Apache License 2.0 5 votes vote down vote up
private void saveCredential() {
    Auth.CredentialsApi.save(mCredentialsApiClient, mCredential).setResultCallback(
            new ResultCallback<Status>() {
                @Override
                public void onResult(@NonNull Status status) {
                    if (status.isSuccess()) {
                        // save options
                        SmartLockHelper.getInstance(mActivity).saveSmartLockOptions(mSmartLockOptions);
                        // credential saved
                        mCredentialsApiClient.disconnect();
                        mStatusSubject.onNext(new RxStatus(status));
                        mStatusSubject.onCompleted();
                    }
                    else if(status.hasResolution()) {
                        // Try to resolve the save request. This will prompt the user if
                        // the credential is new.
                        try {
                            status.startResolutionForResult(mActivity, RC_SAVE);
                        } catch (IntentSender.SendIntentException e) {
                            // Could not resolve the request
                            mCredentialsApiClient.disconnect();
                            mStatusSubject.onError(new Throwable(e.toString()));
                        }
                    }
                    else {
                        // request has no resolution
                        mCredentialsApiClient.disconnect();
                        mStatusSubject.onCompleted();
                    }
                }
            });
}
 
Example #30
Source File: RxSmartLockPasswordsFragment.java    From RxSocialAuth with Apache License 2.0 5 votes vote down vote up
private void deleteCredential() {
    Auth.CredentialsApi.delete(mCredentialsApiClient, mCredential).setResultCallback(new ResultCallback<Status>() {
        @Override
        public void onResult(@NonNull Status status) {
            mCredentialsApiClient.disconnect();
            mStatusSubject.onNext(new RxStatus(status));
            mStatusSubject.onCompleted();

        }
    });
}