本文整理汇总了Java中com.google.android.gms.auth.api.credentials.CredentialRequestResult类的典型用法代码示例。如果您正苦于以下问题:Java CredentialRequestResult类的具体用法?Java CredentialRequestResult怎么用?Java CredentialRequestResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CredentialRequestResult类属于com.google.android.gms.auth.api.credentials包,在下文中一共展示了CredentialRequestResult类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: requestCredentialAndAutoSignIn
import com.google.android.gms.auth.api.credentials.CredentialRequestResult; //导入依赖的package包/类
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());
}
});
}
示例2: onConnected
import com.google.android.gms.auth.api.credentials.CredentialRequestResult; //导入依赖的package包/类
@Override
public void onConnected(@Nullable Bundle bundle) {
googleApi.requestCredentials(new ResultCallback<CredentialRequestResult>() {
@Override
public void onResult(@NonNull CredentialRequestResult result) {
if (result.getStatus().isSuccess()) {
onCredentialRetrieved(result.getCredential());
} else if (result.getStatus().getStatusCode() != CommonStatusCodes.SIGN_IN_REQUIRED && result.getStatus().hasResolution()) {
try {
result.getStatus().startResolutionForResult(LoginActivity.this, GoogleApiAdapter.RETRIEVE_CREDENTIALS);
} catch (IntentSender.SendIntentException e) {
Snackbar.make(vLoginForm, R.string.error_smartlock_failed, Snackbar.LENGTH_LONG);
}
}
}
});
}
示例3: getCredentials
import com.google.android.gms.auth.api.credentials.CredentialRequestResult; //导入依赖的package包/类
/**
* Begin the process of retrieving a {@link Credential} for the device user. This can have
* a few different results:
* 1) If the user has auto sign-in enabled and exactly one previously saved credential,
* {@link SmartLockListener#onCredentialRetrieved(Credential)} will be called and
* you can sign the user in immediately.
* 2) If the user has multiple saved credentials or one saved credential and has disabled
* auto sign-in, you will get the callback {@link SmartLockListener#onShouldShowCredentialPicker()}
* at which point you can choose to show the picker dialog to continue.
* 3) If the user has no saved credentials or cancels the operation, you will receive the
* {@link SmartLockListener#onCredentialRetrievalFailed()} callback.
*/
public void getCredentials() {
CredentialRequest request = buildCredentialRequest();
Auth.CredentialsApi.request(getFragment().getGoogleApiClient(), request)
.setResultCallback(new ResultCallback<CredentialRequestResult>() {
@Override
public void onResult(CredentialRequestResult result) {
if (result.getStatus().isSuccess()) {
// Single credential, auto sign-in
Credential credential = result.getCredential();
getListener().onCredentialRetrieved(credential);
} else if (result.getStatus().hasResolution() &&
result.getStatus().getStatusCode() != CommonStatusCodes.SIGN_IN_REQUIRED) {
// Multiple credentials or auto-sign in disabled. If the status
// code is SIGN_IN_REQUIRED then it is a hint credential, which we
// do not want at this point.
getListener().onShouldShowCredentialPicker();
} else {
// Could not retrieve credentials
getListener().onCredentialRetrievalFailed();
}
}
});
}
示例4: showCredentialPicker
import com.google.android.gms.auth.api.credentials.CredentialRequestResult; //导入依赖的package包/类
/**
* Show the dialog allowing the user to choose a Credential. This method shoud only be called
* after you receive the {@link SmartLockListener#onShouldShowCredentialPicker()} callback.
*/
public void showCredentialPicker() {
CredentialRequest request = buildCredentialRequest();
Activity activity = getFragment().getActivity();
int maskedCode = getFragment().maskRequestCode(RC_READ);
Auth.CredentialsApi.request(getFragment().getGoogleApiClient(), request)
.setResultCallback(new ResolvingResultCallbacks<CredentialRequestResult>(activity, maskedCode) {
@Override
public void onSuccess(CredentialRequestResult result) {
getListener().onCredentialRetrieved(result.getCredential());
}
@Override
public void onUnresolvableFailure(Status status) {
Log.e(TAG, "showCredentialPicker:onUnresolvableFailure:" + status);
}
});
}
示例5: onResult
import com.google.android.gms.auth.api.credentials.CredentialRequestResult; //导入依赖的package包/类
@Override
public void onResult(@NonNull CredentialRequestResult result) {
Status status = result.getStatus();
if (status.isSuccess()) {
// Auto sign-in success
handleCredential(result.getCredential());
return;
} else {
if (status.hasResolution()) {
try {
if (status.getStatusCode() == CommonStatusCodes.RESOLUTION_REQUIRED) {
startIntentSenderForResult(
status.getResolution().getIntentSender(),
RC_CREDENTIALS_READ);
return;
}
} catch (IntentSender.SendIntentException e) {
Log.e(TAG, "Failed to send Credentials intent.", e);
}
} else {
Log.e(TAG, "Status message:\n" + status.getStatusMessage());
}
}
startAuthMethodChoice();
}
示例6: onConnected
import com.google.android.gms.auth.api.credentials.CredentialRequestResult; //导入依赖的package包/类
@Override
void onConnected(final SmartLock smartLock, final Activity activity) {
Log.v(TAG, "Requesting credentials from SmartLock");
getCredentialsApi().request(smartLock.getCredentialClient(), smartLock.newCredentialRequest()).setResultCallback(new ResultCallback<CredentialRequestResult>() {
@Override
public void onResult(CredentialRequestResult credentialRequestResult) {
final com.google.android.gms.common.api.Status status = credentialRequestResult.getStatus();
if (status.isSuccess()) {
final Credential credential = credentialRequestResult.getCredential();
Log.v(TAG, "Retrieved credentials for type " + credential.getAccountType());
smartLock.onCredentialsRetrieved(activity, credential);
} else {
smartLock.onCredentialRetrievalError(activity, status, SmartLock.SMART_LOCK_READ);
}
}
});
}
示例7: requestCredential
import com.google.android.gms.auth.api.credentials.CredentialRequestResult; //导入依赖的package包/类
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();
}
});
}
示例8: shouldHandleRequestSuccess
import com.google.android.gms.auth.api.credentials.CredentialRequestResult; //导入依赖的package包/类
@Test
public void shouldHandleRequestSuccess() throws Exception {
when(status.isSuccess()).thenReturn(true);
when(credentialRequestResult.getCredential()).thenReturn(credential);
task.onConnected(smartLock, activity);
verify(pendingResult).setResultCallback(captor.capture());
final ResultCallback<CredentialRequestResult> resultCallback = captor.getValue();
resultCallback.onResult(credentialRequestResult);
verify(smartLock).onCredentialsRetrieved(eq(activity), eq(credential));
}
示例9: shouldHandleRequestFailure
import com.google.android.gms.auth.api.credentials.CredentialRequestResult; //导入依赖的package包/类
@Test
public void shouldHandleRequestFailure() throws Exception {
when(status.isSuccess()).thenReturn(false);
task.onConnected(smartLock, activity);
verify(pendingResult).setResultCallback(captor.capture());
final ResultCallback<CredentialRequestResult> resultCallback = captor.getValue();
resultCallback.onResult(credentialRequestResult);
verify(smartLock).onCredentialRetrievalError(eq(activity), eq(status), eq(SmartLock.SMART_LOCK_READ));
}
示例10: onResult
import com.google.android.gms.auth.api.credentials.CredentialRequestResult; //导入依赖的package包/类
@Override
public void onResult(@NonNull CredentialRequestResult credentialRequestResult) {
Status status = credentialRequestResult.getStatus();
if (status.isSuccess()) {
onCredentialRetrieved(credentialRequestResult.getCredential());
} else {
resolveResult(status);
}
}
示例11: requestCredential
import com.google.android.gms.auth.api.credentials.CredentialRequestResult; //导入依赖的package包/类
/**
* Request credential
*
* @return a PublishSubject<CredentialRequestResult>
*/
public PublishSubject<CredentialRequestResult> requestCredential() {
mRequestSubject = PublishSubject.create();
mRxSmartLockPasswordsFragment.requestCredential(mRequestSubject);
return mRequestSubject;
}
示例12: requestCredentials
import com.google.android.gms.auth.api.credentials.CredentialRequestResult; //导入依赖的package包/类
private void requestCredentials() {
mSignInButton.setEnabled(false);
mIsRequesting = true;
CredentialRequest request = new CredentialRequest.Builder()
.setPasswordLoginSupported(true)
.setAccountTypes(IdentityProviders.GOOGLE, IdentityProviders.TWITTER)
.build();
Auth.CredentialsApi.request(mGoogleApiClient, request).setResultCallback(
new ResultCallback<CredentialRequestResult>() {
@Override
public void onResult(CredentialRequestResult credentialRequestResult) {
// mIsRequesting = false;
Status status = credentialRequestResult.getStatus();
if (credentialRequestResult.getStatus().isSuccess()) {
// Successfully read the credential without any user interaction, this
// means there was only a single credential and the user has auto
// sign-in enabled.
Credential credential = credentialRequestResult.getCredential();
processRetrievedCredential(credential);
} else if (status.getStatusCode() == CommonStatusCodes.RESOLUTION_REQUIRED) {
// setFragment(null);
// This is most likely the case where the user has multiple saved
// credentials and needs to pick one.
resolveResult(status, RC_READ);
} else if (status.getStatusCode() == CommonStatusCodes.SIGN_IN_REQUIRED) {
// setFragment(null);
// This is most likely the case where the user does not currently
// have any saved credentials and thus needs to provide a username
// and password to sign in.
Log.d(TAG, "Sign in required");
mSignInButton.setEnabled(true);
} else {
Log.w(TAG, "Unrecognized status code: " + status.getStatusCode());
// setFragment(null);
mSignInButton.setEnabled(true);
}
}
}
);
}
示例13: requestCredentials
import com.google.android.gms.auth.api.credentials.CredentialRequestResult; //导入依赖的package包/类
public void requestCredentials(ResultCallback<? super CredentialRequestResult> callback) {
Auth.CredentialsApi.request(client, new CredentialRequest.Builder()
.setPasswordLoginSupported(true)
.setAccountTypes(IdentityProviders.GOOGLE)
.build()).setResultCallback(callback);
}
示例14: shouldSetResultCallback
import com.google.android.gms.auth.api.credentials.CredentialRequestResult; //导入依赖的package包/类
@Test
public void shouldSetResultCallback() throws Exception {
task.onConnected(smartLock, activity);
verify(pendingResult).setResultCallback(Matchers.<ResultCallback<CredentialRequestResult>>any());
}