android电话拔打

来源:互联网 发布:网络利大于弊的提问词 编辑:程序博客网 时间:2024/04/18 12:06
public  void CallPhone( String phoneNum){  

try {
if (phoneNum!=null&&!phoneNum.equals("")) {


phoneNum=phoneNum.replace("-", "");
Pattern p = Pattern.compile("\\d+?");
Matcher match = p.matcher(phoneNum);
//正则验证输入的是否为数字
if(match.matches()){
Intent intent=new Intent(Intent.ACTION_DIAL,Uri.parse("tel:"+phoneNum));
startActivity(intent);
}else{

TispToastFactory.getToast(this, "号码格式不正确!");
}
}
} catch (PatternSyntaxException e) {

e.printStackTrace();
}

原创粉丝点击