Java tutorial
//package com.java2s; //License from project: Apache License import android.accounts.Account; import android.accounts.AccountManager; import android.content.Context; import java.util.ArrayList; import java.util.List; public class Main { static List<String> getEmailAddresses(Context context, int limit) { ArrayList<String> emails = new ArrayList<String>(); AccountManager am = AccountManager.get(context); if (am == null) { return emails; } Account[] accounts = am.getAccountsByType("com.google"); if (accounts == null || accounts.length == 0) { return emails; } for (Account a : accounts) { if (a.name == null || a.name.length() == 0) { continue; } emails.add(a.name.trim().toLowerCase()); } while (emails.size() > limit) { emails.remove(emails.size() - 1); } return emails; } }