Here you can find the source of createUrl(final String rootUrl, final String indivisualHost, final String featurePath, final int index, List
public static String createUrl(final String rootUrl, final String indivisualHost, final String featurePath, final int index, List<NameValuePair> pairs)
//package com.java2s; import java.net.URI; import java.util.List; import java.util.Random; import org.apache.http.NameValuePair; import android.net.Uri; import android.util.Log; public class Main { public static String createUrl(final String rootUrl, final String indivisualHost, final String featurePath, final int index, List<NameValuePair> pairs) { Uri.Builder builder = new Uri.Builder(); try {//from w w w .j a va 2 s. c o m URI uri = new URI(rootUrl); String urlQuery = createQueryUrl(indivisualHost, featurePath, index, pairs); builder.scheme(uri.getScheme()); builder.authority(uri.getAuthority()); builder.path(uri.getPath() + "/"); builder.appendQueryParameter("guid", "ON"); builder.appendQueryParameter("url", urlQuery); } catch (Exception e) { e.printStackTrace(); } return builder.build().toString(); } public static String createQueryUrl(final String indivisualHost, final String featurePath, final int index, List<NameValuePair> pairs) { String path = featurePath; if (path.endsWith("/")) path += "/"; if (index > 0) { path = path + Integer.toString(index); } Uri.Builder builder = new Uri.Builder(); builder.scheme("http"); builder.authority(indivisualHost); builder.path(path); for (NameValuePair pair : pairs) { builder.appendQueryParameter(pair.getName(), pair.getValue()); } builder.appendQueryParameter("rnd", Integer.toString(new Random().nextInt(100000000))); try { String uri = builder.build().toString(); Log.d("MbgaUtils", "QueryUrl: " + uri); URI uriQuery = new URI(uri); return uriQuery.toASCIIString(); } catch (Exception e) { // TODO: handle exception Log.d("MbgaUtils", e.getMessage()); return ""; } } }