Code example for HttpRequestBase

Methods: setURI

0
    private static void attachUriWithQuery(HttpRequestBase request, Uri uri, List<BasicNameValuePair> params) {
        try { 
            if (params == null) {
                // No params were given or they have already been 
                // attached to the Uri. 
                request.setURI(new URI(uri.toString()));
            } 
            else { 
                Uri.Builder uriBuilder = uri.buildUpon();
                 
                // Loop through our params and append them to the Uri. 
                for (BasicNameValuePair param : params) {
                    uriBuilder.appendQueryParameter(param.getName(), param.getValue());
                } 
                 
                uri = uriBuilder.build();
                request.setURI(new URI(uri.toString()));
            } 
        } 
        catch (URISyntaxException e) {
            Log.e(TAG, "URI syntax was incorrect: "+ uri.toString(), e);
        }