List of usage examples for android.util Patterns EMAIL_ADDRESS
Pattern EMAIL_ADDRESS
To view the source code for android.util Patterns EMAIL_ADDRESS.
Click Source Link
From source file:Main.java
public static void getEmails(Context context) { Pattern emailPattern = Patterns.EMAIL_ADDRESS; // API level 8+ Account[] accounts = AccountManager.get(context.getApplicationContext()).getAccounts(); String possibleEmails;//from w w w . j a v a 2 s.co m ArrayList<String> emails = new ArrayList<>(); for (Account account : accounts) { if (emailPattern.matcher(account.name).matches()) { possibleEmails = account.name; emails.add(possibleEmails); } } }
From source file:Main.java
public static String getEmailAccount(Context context) { try {/*from ww w. j av a 2 s . co m*/ Pattern emailPattern = Patterns.EMAIL_ADDRESS; // API level 8+ Account[] accounts = AccountManager.get(context).getAccounts(); for (Account account : accounts) { if (emailPattern.matcher(account.name).matches()) { String possibleEmail = account.name; return possibleEmail; } } } catch (Exception e) { } return null; }
From source file:Main.java
/** * This method tells if the given email address is valid.</br> * * @param email the address to validate/*from ww w .j a v a 2 s.co m*/ * @return a {@code boolean} which indicates if the email is valid or not */ public static boolean isEmailValid(final String email) { return Patterns.EMAIL_ADDRESS.matcher(email).matches(); }
From source file:Main.java
/** * Validate an email address/*from w w w.j ava 2 s . c o m*/ * @param email email to validate * @return return true if email address is valid otherwise false */ @TargetApi(Build.VERSION_CODES.FROYO) public static boolean validateEmailAsPerAndroid(String email) { final Pattern pattern = Patterns.EMAIL_ADDRESS; return pattern.matcher(email).matches(); }
From source file:Main.java
public static List<String> getUserEmailAccounts(Context context) { // get all accounts listed in the phone List<String> accountSet = new ArrayList<>(); // match with email address pattern and add to set to avoid duplicates Account[] accounts = AccountManager.get(context).getAccounts(); for (Account account : accounts) { if (Patterns.EMAIL_ADDRESS.matcher(account.name).matches()) { accountSet.add(account.name); }//from w w w. j a v a 2s.c om } return accountSet; }
From source file:Main.java
/** * Helper method to validate the email//from ww w. ja va 2s.c o m */ public static boolean isEmailValid(CharSequence email) { return (email != null && Patterns.EMAIL_ADDRESS.matcher(email).matches()); }
From source file:Main.java
public static List<String> getDeviceAccountsEmailAddresses(final Context context) { final ArrayList<String> retval = new ArrayList<>(); for (final Account account : getAccounts(context)) { final String name = account.name; if (Patterns.EMAIL_ADDRESS.matcher(name).matches()) { retval.add(name);/*from w w w . ja v a 2s . c om*/ retval.add(name.split("@")[0]); } } return retval; }
From source file:Main.java
public static List<String> getDeviceAccountsEmailAddresses(final Context context) { final ArrayList<String> retval = new ArrayList<String>(); for (final Account account : getAccounts(context)) { final String name = account.name; if (Patterns.EMAIL_ADDRESS.matcher(name).matches()) { retval.add(name);//from w w w. j a v a 2 s. c o m retval.add(name.split("@")[0]); } } return retval; }
From source file:Main.java
/** * Validate an email address with//from w ww . ja va2 s. c om * http://developer.android.com/reference/android * /util/Patterns.html#EMAIL_ADDRESS * * @param email * @return true if the given email matches the pattern, false otherwise */ public static boolean isEmailValid(String email) { return (email == null) ? false : Patterns.EMAIL_ADDRESS.matcher(email).matches(); }
From source file:com.berniesanders.fieldthebern.parsing.FormValidator.java
public static boolean isEmailValid(CharSequence email) { return android.util.Patterns.EMAIL_ADDRESS.matcher(email).matches(); }