2011-06-12 3 views
2

Google 계정, Facebook 계정, Twitter 계정 등 사용자 ID와 비밀번호가 유효한지 확인하고 싶습니다. AccountManager 클래스에서 confirmCredentials API를 찾았습니다. 이 API를 사용하여 계정의 비밀번호를 확인할 수 있습니까?
쓸데 checkCredentials 사용자의 비밀번호를 확인하는 API가 유효하지만 ANR이 발생하고 비밀번호 결과가 유효하지 않습니까?
이 API에 대한 경험이 있습니까? 또는 ID 및 암호를 Andoroid에서 확인할 수있는 방법이 있습니까?
모든 정보 또는 단서가 인정 될 것입니다. 고맙습니다.누구나 AccountManager에서 confirmCredentials API를 사용하는 경험이 있습니까 (Android)

답변

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(); 
    } 
    } 
관련 문제