6
我不明白方法confirmCredentials
是如何工作的。我從來沒有在Android UI中看到任何選項,比如「Confirm Credentials」等,只有「Create account」和「Remove account」。誰和什麼時候應該調用基於AbstractAccountAuthenticator的類的方法confirmCredentials?
我不明白方法confirmCredentials
是如何工作的。我從來沒有在Android UI中看到任何選項,比如「Confirm Credentials」等,只有「Create account」和「Remove account」。誰和什麼時候應該調用基於AbstractAccountAuthenticator的類的方法confirmCredentials?
如果您想要將設備上的Gmail帳戶用作驗證方法,請使用它。 NFCSecure在您打開應用程序時使用它,強制您使用Gmail登錄。
public void verifyAuth(Bundle b) throws IllegalArgumentException {
accountManager.confirmCredentials(getImportantAccount(importantEmail), b, (Activity) c, new OnConfirmed(), null);
}
public void attemptLogin() {
mEmailView.setError(null);
mPasswordView.setError(null);
mEmail = mEmailView.getText().toString();
mPassword = mPasswordView.getText().toString();
boolean cancel = false;
View focusView = null;
if (TextUtils.isEmpty(mPassword)) {
mPasswordView.setError(getString(R.string.error_field_required));
focusView = mPasswordView;
cancel = true;
} else if (mPassword.length() < 4) {
mPasswordView.setError(getString(R.string.error_invalid_password));
focusView = mPasswordView;
cancel = true;
}
if (TextUtils.isEmpty(mEmail)) {
mEmailView.setError(getString(R.string.error_field_required));
focusView = mEmailView;
cancel = true;
} else if (!mEmail.contains("@")) {
mEmailView.setError(getString(R.string.error_invalid_email));
focusView = mEmailView;
cancel = true;
}
if (cancel) {
focusView.requestFocus();
} else {
mLoginStatusMessageView.setText(R.string.login_progress_signing_in);
showProgress(true);
gAuth = new GoogleAuthentication(ctx, mEmailView.getText().toString());
gAuth.setUserConfirmedListener(SettingsUnlockActivity.this);
Bundle b = new Bundle();
b.putString(AccountManager.KEY_PASSWORD, mPasswordView.getText().toString());
try {
gAuth.verifyAuth(b);
} catch (IllegalArgumentException e) {
doUnSuccessfulLogin();
}
}
}