2014-02-19 4 views
2

이 코드 부분을 사용하지만 null을 반환합니다.기기에서 활성 Facebook 계정을 얻으려면 어떻게해야하나요?

Pattern emailPattern = Patterns.EMAIL_ADDRESS; // API level 8+ 
accounts = AccountManager.get(Login.this).getAccountsByType("com.facebook"); 
String possibleEmail; 

for (Account account : accounts) 
{ 
    if (emailPattern.matcher(account.name).matches()) 
    { 
     possibleEmail = account.name; 
     Log.e("Email", possibleEmail); 
    } 
} 

하지만 ("com.google")에서 작동합니다.

답변

0

모든 유형을 출력하고 액세스 할 때 사용하는 것이 더 낫습니다. 유형 이름별로 압축을 풀 때 액세스가 필요합니다. 페이스 북 내 테스트 장치 유형에서와 마찬가지로

Pattern emailPattern = Patterns.EMAIL_ADDRESS; // API level 8+ 

    AccountManager acMng = AccountManager.get(this.getApplicationContext()); 
    if(acMng!=null) {   

    Account[] accounts = acMng.getAccounts(); 
    String possibleEmail; 

    if(accounts!= null) { 
    for (Account account : accounts) 
    { 
     Log.e((account.name , account.type); 
     if (emailPattern.matcher(account.name).matches()) 
     { 
      possibleEmail = account.name; 
      Log.e(("Email :", possibleEmail); 
     } 
    } 
    } 

입니다 - com.facebook.auth.login

그래서 나는 그것을 할 필요가 있다고 생각 :

accounts = AccountManager.get(Login.this).getAccountsByType("com.facebook.auth.login"); 
+0

덕분에 네하은 지금이다 일. – user3326573

+0

쿨 !! 그때 plz 대답을 표시하십시오 :) – Neha

+0

@ 네하 부인이 링크를 확인하십시오 http://stackoverflow.com/questions/22481360/how-can-i-get-email-ids-of-yahoo-microsoft-account –

관련 문제