Example usage for android.webkit URLUtil isHttpUrl

List of usage examples for android.webkit URLUtil isHttpUrl

Introduction

In this page you can find the example usage for android.webkit URLUtil isHttpUrl.

Prototype

public static boolean isHttpUrl(String url) 

Source Link

Usage

From source file:com.shinymayhem.radiopresets.ServiceRadioPlayer.java

public static boolean validateUrl(String url) {

    if (!URLUtil.isHttpUrl(url) && !URLUtil.isHttpsUrl(url)) {
        //if (LOCAL_LOGV) log("not a valid http or https url", "v");
        return false;
    }//  ww  w.  j  a va2s .  c  o  m
    //check for empty after prefix
    if (url.equals("http://") || url.equals("https://")) {
        return false;
    }

    MediaPlayer mediaPlayer = new MediaPlayer();
    mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
    try {
        mediaPlayer.setDataSource(url);
        mediaPlayer.release();
    } catch (IOException e) {
        return false;
    }
    return true;
}