android.util.Patterns#EMAIL_ADDRESS源码实例Demo

下面列出了android.util.Patterns#EMAIL_ADDRESS 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: XERUNG   文件: VerifyOTP.java
private ArrayList<String> getUserEmail(){

		ArrayList<String> email = new ArrayList<String>();

		Pattern emailPattern = Patterns.EMAIL_ADDRESS; // API level 8+
		Account[] accounts = AccountManager.get(VerifyOTP.this).getAccounts();
		for (Account account : accounts) {
			if (emailPattern.matcher(account.name).matches()) {
				String possibleEmail = account.name;
				if(possibleEmail != null)
					if(possibleEmail.length() !=0 ){
						email.add(possibleEmail);
					}
			}
		}		
		return email;

	}
 
源代码2 项目: XERUNG   文件: VerifyOTP.java
private ArrayList<String> getUserEmail(){

		ArrayList<String> email = new ArrayList<String>();

		Pattern emailPattern = Patterns.EMAIL_ADDRESS; // API level 8+
		Account[] accounts = AccountManager.get(VerifyOTP.this).getAccounts();
		for (Account account : accounts) {
			if (emailPattern.matcher(account.name).matches()) {
				String possibleEmail = account.name;
				if(possibleEmail != null)
					if(possibleEmail.length() !=0 ){
						email.add(possibleEmail);
					}
			}
		}		
		return email;

	}
 
源代码3 项目: capacitor-email   文件: EmailPlugin.java
@PluginMethod()
public void isAvailable(PluginCall call) {
    String app = call.getString("alias", "");
    boolean has = checkPermission();
    JSObject object = new JSObject();
    PackageManager pm = getActivity().getPackageManager();
    if (aliases.has(app)) {
        app = aliases.getString(app);
    }
    object.put("hasAccount", false);

    if (has) {
        AccountManager am;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            am = AccountManager.get(getContext());
        } else {
            am = AccountManager.get(getContext());
        }

        Pattern emailPattern = Patterns.EMAIL_ADDRESS;
        for (Account account : am.getAccounts()) {
            if (emailPattern.matcher(account.name).matches()) {
                object.put("hasAccount", true);
            }
        }

    }

    try {
        ApplicationInfo info = pm.getApplicationInfo(app, 0);
        object.put("hasApp", true);
    } catch (PackageManager.NameNotFoundException e) {
        object.put("hasApp", false);
    } finally {
        call.success(object);
    }

}
 
源代码4 项目: actor-platform   文件: BaseAuthFragment.java
private String getSuggestedEmailChecked() {
    Pattern emailPattern = Patterns.EMAIL_ADDRESS;
    Account[] accounts = AccountManager.get(getActivity()).getAccounts();
    for (Account account : accounts) {
        if (emailPattern.matcher(account.name).matches()) {
            return account.name;
        }
    }

    return null;
}
 
源代码5 项目: echo   文件: UserInfo.java
public static String getUserEmail(Context c) {
    Pattern emailPattern = Patterns.EMAIL_ADDRESS; // API level 8+
    Account[] accounts = AccountManager.get(c).getAccounts();
    for (Account account : accounts) {
        if (emailPattern.matcher(account.name).matches()) {
            return account.name;
        }
    }
    return "";
}
 
源代码6 项目: EmailAutoCompleteTextView   文件: AccountUtil.java
/**
 * Returns true if the given string is an email.
 */
private static boolean isEmail(String account) {

    if (TextUtils.isEmpty(account)) {
        return false;
    }

    final Pattern emailPattern = Patterns.EMAIL_ADDRESS;
    final Matcher matcher = emailPattern.matcher(account);
    return matcher.matches();
}
 
源代码7 项目: Cangol-appcore   文件: ValidatorUtils.java
/**
 * 验证email地址格式是否正确
 *
 * @param str
 * @return
 */
public static boolean validateEmail(String str) {
    if (str == null || "".equals(str)) {
        return false;
    }
    final Pattern p = Patterns.EMAIL_ADDRESS;
    final Matcher m = p.matcher(str);
    return m.matches();
}
 
源代码8 项目: android-chromium   文件: IntentHelper.java
/**
 * Triggers a send email intent.  If no application has registered to receive these intents,
 * this will fail silently.
 *
 * @param context The context for issuing the intent.
 * @param email The email address to send to.
 * @param subject The subject of the email.
 * @param body The body of the email.
 * @param chooserTitle The title of the activity chooser.
 * @param fileToAttach The file name of the attachment.
 */
@CalledByNative
static void sendEmail(Context context, String email, String subject, String body,
        String chooserTitle, String fileToAttach) {
    Set<String> possibleEmails = new HashSet<String>();

    if (!TextUtils.isEmpty(email)) {
        possibleEmails.add(email);
    } else {
        Pattern emailPattern = Patterns.EMAIL_ADDRESS;
        Account[] accounts = AccountManager.get(context).getAccounts();
        for (Account account : accounts) {
            if (emailPattern.matcher(account.name).matches()) {
                possibleEmails.add(account.name);
            }
        }
    }

    Intent send = new Intent(Intent.ACTION_SEND);
    send.setType("message/rfc822");
    if (possibleEmails.size() != 0) {
        send.putExtra(Intent.EXTRA_EMAIL,
                possibleEmails.toArray(new String[possibleEmails.size()]));
    }
    send.putExtra(Intent.EXTRA_SUBJECT, subject);
    send.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(body));
    if (!TextUtils.isEmpty(fileToAttach)) {
        File fileIn = new File(fileToAttach);
        send.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(fileIn));
    }

    try {
        Intent chooser = Intent.createChooser(send, chooserTitle);
        // we start this activity outside the main activity.
        chooser.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(chooser);
    } catch (android.content.ActivityNotFoundException ex) {
        // If no app handles it, do nothing.
    }
}
 
源代码9 项目: android-chromium   文件: IntentHelper.java
/**
 * Triggers a send email intent.  If no application has registered to receive these intents,
 * this will fail silently.
 *
 * @param context The context for issuing the intent.
 * @param email The email address to send to.
 * @param subject The subject of the email.
 * @param body The body of the email.
 * @param chooserTitle The title of the activity chooser.
 * @param fileToAttach The file name of the attachment.
 */
@CalledByNative
static void sendEmail(Context context, String email, String subject, String body,
        String chooserTitle, String fileToAttach) {
    Set<String> possibleEmails = new HashSet<String>();

    if (!TextUtils.isEmpty(email)) {
        possibleEmails.add(email);
    } else {
        Pattern emailPattern = Patterns.EMAIL_ADDRESS;
        Account[] accounts = AccountManager.get(context).getAccounts();
        for (Account account : accounts) {
            if (emailPattern.matcher(account.name).matches()) {
                possibleEmails.add(account.name);
            }
        }
    }

    Intent send = new Intent(Intent.ACTION_SEND);
    send.setType("message/rfc822");
    if (possibleEmails.size() != 0) {
        send.putExtra(Intent.EXTRA_EMAIL,
                possibleEmails.toArray(new String[possibleEmails.size()]));
    }
    send.putExtra(Intent.EXTRA_SUBJECT, subject);
    send.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(body));
    if (!TextUtils.isEmpty(fileToAttach)) {
        File fileIn = new File(fileToAttach);
        send.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(fileIn));
    }

    try {
        Intent chooser = Intent.createChooser(send, chooserTitle);
        // we start this activity outside the main activity.
        chooser.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(chooser);
    } catch (android.content.ActivityNotFoundException ex) {
        // If no app handles it, do nothing.
    }
}
 
源代码10 项目: Linphone4Android   文件: CreateAccountFragment.java
private boolean isEmailCorrect(String email) {
	Pattern emailPattern = Patterns.EMAIL_ADDRESS;
	return emailPattern.matcher(email).matches();
}
 
源代码11 项目: Linphone4Android   文件: InAppPurchaseHelper.java
private boolean isEmailCorrect(String email) {
   	Pattern emailPattern = Patterns.EMAIL_ADDRESS;
   	return emailPattern.matcher(email).matches();
}
 
源代码12 项目: Cybernet-VPN   文件: FeedBackActivityFragment.java
@Override
public void onClick(View v)
{
    nameValue = name.getText().toString();
    emailvalue = email.getText().toString();
    phoneValue = phone.getText().toString();
    messageValue = message.getText().toString();

    Log.d("mylog",nameValue+messageValue);


    int flagName=0, flagEmail=0, flagMsg=0, flagPhone=0;

    Pattern emailPattern = Patterns.EMAIL_ADDRESS;
    Pattern phonePattern = Patterns.PHONE;

    boolean emailVal= emailPattern.matcher(emailvalue).matches();
    boolean phoneVal =phonePattern.matcher(phoneValue).matches();
    if(emailVal!=true)
    {
        email.setError("Invalid Email");
        flagEmail=0;
    }
    else
    {
        flagEmail=1;
    }

    if(phoneVal==false)
    {
        phone.setError("Please enter your phone correctly ");
        flagPhone=0;
    }
    else
    {
        flagPhone=1;
    }
    if(nameValue==null || nameValue.equals(" ") || nameValue.equals(""))
    {
        name.setError("Please enter your name");
        flagName=0;
    }
    else
    {
        flagName=1;
    }
    if(messageValue.isEmpty())
    {
        message.setError("Please enter the message");
        flagMsg=0;
    }
    else
    {
        flagMsg=1;
    }

    if (flagEmail==1 && flagPhone==1 && flagMsg==1 && flagName==1)
    {
        String s= String.valueOf(flagMsg+flagEmail+flagName+flagPhone);
        //Log.d("hello",s);

        FeedBackSend feedBackSend=new FeedBackSend();
        feedBackSend.execute();
    }

}
 
源代码13 项目: data-binding-validator   文件: EmailTypeRule.java
@Override
protected boolean isValid(TextView view) {
    Pattern emailPattern = Patterns.EMAIL_ADDRESS;
    return emailPattern.matcher(view.getText()).matches();
}
 
 方法所在类
 同类方法