Validates given url string using android.util.Patterns#WEB_URL pattern - Android Network

Android examples for Network:URL

Description

Validates given url string using android.util.Patterns#WEB_URL pattern

Demo Code


//package com.java2s;
import android.text.TextUtils;
import android.util.Patterns;

public class Main {
    /**/*from   ww w .  j a v  a2  s  .c  o  m*/
     * Validates given url string using {@link android.util.Patterns#WEB_URL} pattern
     *
     * @param url to validate
     * @return true if url is valid, otherwise false
     */
    public static boolean isValidUrl(final String url) {
        if (TextUtils.isEmpty(url)) {
            return false;
        }

        return Patterns.WEB_URL.matcher(url).matches();
    }
}

Related Tutorials