Example usage for android.webkit URLUtil isDataUrl

List of usage examples for android.webkit URLUtil isDataUrl

Introduction

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

Prototype

public static boolean isDataUrl(String url) 

Source Link

Usage

From source file:android.webkit.LoadListener.java

/**
 * Sets the current URL associated with this load.
 *///from w ww.ja  v a 2  s.  c  o  m
void setUrl(String url) {
    if (url != null) {
        if (URLUtil.isDataUrl(url)) {
            // Don't strip anchor as that is a valid part of the URL
            mUrl = url;
        } else {
            mUrl = URLUtil.stripAnchor(url);
        }
        mUri = null;
        if (URLUtil.isNetworkUrl(mUrl)) {
            try {
                mUri = new WebAddress(mUrl);
            } catch (ParseException e) {
                e.printStackTrace();
            }
        }
    }
}

From source file:android.webkit.LoadListener.java

/**
 * Guesses MIME type if one was not specified. Defaults to 'text/html'. In
 * addition, tries to guess the MIME type based on the extension.
 *
 *//*  www . jav a  2 s. co  m*/
private void guessMimeType() {
    // Data urls must have a valid mime type or a blank string for the mime
    // type (implying text/plain).
    if (URLUtil.isDataUrl(mUrl) && mMimeType.length() != 0) {
        cancel();
        final String text = mContext.getString(com.android.internal.R.string.httpErrorBadUrl);
        error(EventHandler.ERROR_BAD_URL, text);
    } else {
        // Note: This is ok because this is used only for the main content
        // of frames. If no content-type was specified, it is fine to
        // default to text/html.
        mMimeType = "text/html";
        String newMimeType = guessMimeTypeFromExtension();
        if (newMimeType != null) {
            mMimeType = newMimeType;
        }
    }
}