Checks to see if the your contains the authority "youtube.com" - Android App

Android examples for App:Popular App

Description

Checks to see if the your contains the authority "youtube.com"

Demo Code


//package com.java2s;
import android.net.Uri;
import android.text.TextUtils;

public class Main {
    /****//from   w w w .  j a v a  2 s .c o m
     * Checks to see if the your contains the authority "youtube.com"
     ****/
    public static boolean isYouTubeUrl(String url) {

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

        Uri uri = Uri.parse(url);
        String authority = uri.getAuthority();
        if (!TextUtils.isEmpty(authority)
                && authority.contains("youtube.com")) {
            return true;
        } else {
            return false;
        }
    }
}

Related Tutorials