android检验url是否有效

import android.text.TextUtils;

import android.util.Patterns;

if (TextUtils.isEmpty(url)) { 

Toast.makeText(this,"URL 不能为空~", Toast.LENGTH_SHORT).show(); 
return false;

}

if (!Patterns.WEB_URL.matcher(url.toString()).matches()) { 
    Toast.makeText(this,"URL 非法,请输入有效的URL链接:"+url, Toast.LENGTH_SHORT).show(); 
return false;
}

猜你喜欢

转载自blog.csdn.net/ahaitongxue/article/details/80507426
今日推荐