사용예.


ArrayList<AccountInfo> arrAccountInfo = getAccountInfoList();


for (int i=0; i<arrAccountInfo.size(); i++) {

Log.d("값 확인", "account type : " + arrAccountInfo.get(i).getAccountType() + " / " + "account name : " + arrAccountInfo.get(i).getAccountName() );

}




//단말기 계정정보 얻기
public ArrayList<AccountInfo> getAccountList() {
ArrayList<AccountInfo> arrAccountInfo = new ArrayList<AccountInfo>();

Account[] accounts = AccountManager.get(this.context).getAccounts();
Account account = null;

for(int i=0;i<accounts.length;i++) {
account = accounts[i];
if ( (!account.type.equals("com.google") && account.name.toLowerCase().contains("phone")==true) || account.type.equals("com.google")) { //구글 및 폰 계정만 얻기
AccountInfo accountInfo = new AccountInfo();
accountInfo.setAccountType(account.type);
accountInfo.setAccountName(account.name);
arrAccountInfo.add(accountInfo);
}

}


return arrAccountInfo;

}



AccountInfo.java

public class AccountInfo {
String account_type;
String account_name;

public void setAccountType(String account_type) { this.account_type = account_type; }
public String getAccountType() { return this.account_type; }

public void setAccountName(String account_name) { this.account_name = account_name; }
public String getAccountName() { return this.account_name; }

}


Posted by yespia.net piacom