Кто и когда должен вызовать метод подтверждения класса AbstractAccountAuthenticator?

StackOverflow https://stackoverflow.com/questions/9341042

Вопрос

Я не понимаю, как метод confirmCredentials работает. Я никогда не видел никаких вариантов в пользовательском интерфейсе Android, таких как «Подтверждение учетных данных» или что -то в этом роде, есть только «создать учетную запись» и «удалить учетную запись».

Это было полезно?

Решение

Он используется, если вы хотите использовать учетную запись 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();
        }
    }
}
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top