Example usage for android.webkit URLUtil guessUrl

List of usage examples for android.webkit URLUtil guessUrl

Introduction

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

Prototype

public static String guessUrl(String inUrl) 

Source Link

Document

Cleans up (if possible) user-entered web addresses

Usage

From source file:gr.ndre.scuttloid.ScuttleAPI.java

protected String getBaseURL() {
    return URLUtil.guessUrl(this.url);
}

From source file:org.ohmage.authenticator.AuthenticatorActivity.java

/**
 * Ensures that the server url provided is valid. Once it is made valid, it
 * is set as the server url./*from   w ww .j  a  va 2 s  .c  om*/
 * 
 * @return
 */
private boolean ensureServerUrl() {
    String text = mServerEdit.getText().toString();

    if (TextUtils.isEmpty(text))
        return false;

    // Assume they want https by default
    URI uri = URI.create(text.split(" ")[0]);
    if (uri.getScheme() == null) {
        text = "https://" + text;
    }

    text = URLUtil.guessUrl(text);

    if (URLUtil.isHttpsUrl(text) || URLUtil.isHttpUrl(text)) {
        mServerEdit.setText(text);
        return true;
    }

    return false;
}