Android URI Create createUriFromString(String uriString)

Here you can find the source of createUriFromString(String uriString)

Description

Sipgate sends "URIs" without the "//", so we have to insert them.

License

Open Source License

Parameter

Parameter Description
uriString - the URI string from Sipgate (without "//")

Return

A Uri object

Declaration

public static Uri createUriFromString(String uriString) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import android.net.Uri;

public class Main {
    /**/*from w ww. ja  v a  2 s.  c  o m*/
     * Sipgate sends "URIs" without the "//", so we have to insert them.
     * 
     * @param uriString - the URI string from Sipgate (without "//")
     * @return A Uri object
     */
    public static Uri createUriFromString(String uriString) {

        Uri uri;

        if (uriString.startsWith("sip://")) {
            uri = Uri.parse(uriString);
        } else {
            StringBuilder uriBuilder = new StringBuilder(uriString);
            uri = Uri.parse(uriBuilder.insert(4, "//").toString());
        }

        return uri;

    }
}

Related

  1. makeUriString(Uri uri)