2

ユーザー ID とパスワードが有効かどうか (Google アカウント、Facebook アカウント、Twitter アカウントなど) を確認したい。AccountManager クラスのconfirmCredentials APIを見つけました。この API を使用してアカウントのパスワードを確認できますか?
ユーザーのパスワードが有効かどうかをチェックするために、このcheckCredentials API を作成しましたが、ANR が発生し、パスワードが有効かどうかの結果を取得できませんか?
この API について、または Andoroid で ID とパスワードを検証する方法について何か経験はありますか?
情報や手がかりをいただければ幸いです。どうもありがとうございました。

4

1 に答える 1

1

アプリで confirmCredentials を使用しました。それが役立つ場合に備えて、以下にサンプルコードをいくつか入れました...

public class MyActivity implements AccountManagerCallback<Bundle>

<snip>

    // Get the user to confirm their credentials 
    Account account = new Account("username", "com.mydomain.myapp");

    // The result of this call is handled in the
    // run(AccountManagerFuture<Bundle> response) method below
    AccountManager.get(this).confirmCredentials(account,
                                                null,
                                                this,
                                                this,
                                                null);

<snip>

  /**
   * Handle callbacks from the {@link AccountManager} methods
   */
  @Override
  public void run(AccountManagerFuture<Bundle> response)
  {
    try
    {
      // This call blocks while waiting for result from confirmCredentials
      Bundle result = response.getResult();

      // Handle the result
    }
    catch (OperationCanceledException e)
    {
      // User cancelled login
      e.printStackTrace();
    }
    catch (AuthenticatorException e)
    {
      // Failed to login
      e.printStackTrace();
    }
    catch (IOException e)
    {
      e.printStackTrace();
    }
    finally
    {
      // Always exit
      finish();
    }
  }
于 2011-10-24T18:29:06.190 に答える