Java Code Examples for android.util.Patterns#PHONE
The following examples show how to use
android.util.Patterns#PHONE .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ValidatorUtils.java From Cangol-appcore with Apache License 2.0 | 5 votes |
/** * 验证电话号码格式是否正确 * * @param str * @return */ public static boolean validatePhone(String str) { if (str == null || "".equals(str)) { return false; } final Pattern p = Patterns.PHONE; final Matcher m = p.matcher(str); return m.matches(); }
Example 2
Source File: FeedBackActivityFragment.java From Cybernet-VPN with GNU General Public License v3.0 | 4 votes |
@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(); } }