8

我不明白方法是如何confirmCredentials工作的。我从未在 Android UI 中看到任何选项,例如“确认凭据”之类的,只有“创建帐户”和“删除帐户”。

4

1 回答 1

2

如果您想将设备上的 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();
        }
    }
}
于 2013-01-28T15:33:02.677 回答