I have class with static method
我有静态方法的课
public class GrandUtils {
/**
* Return list of existing user's emails
*
* @param c context of the app
* @return list of existing accounts in system or empty list
*/
public static Set<String> getAccountsList(Context c) {
Set<String> accountsList = new HashSet<>();
Pattern emailPattern = Patterns.EMAIL_ADDRESS; // API level 8+
Account[] accounts = AccountManager.get(c).getAccounts();
for (Account account : accounts) {
if (emailPattern.matcher(account.name).matches()) {
accountsList.add(account.name);
}
}
return accountsList;
}
}
pu