Java tutorial
//package com.java2s; import android.accounts.Account; import android.accounts.AccountManager; public class Main { public static Account getAccountFromAccountName(AccountManager accountManager, String accountName) { Account accounts[] = accountManager.getAccounts(); for (int i = 0; i < accounts.length; ++i) if (accountName.equals(accounts[i].name)) return accounts[i]; return null; } }