title: Android: Create a URL using Uri.Builder().build() with port numbers
body: <p><code>Uri.Builder.build()</code> works quite well with normal URLs, but it fails with port number support.</p>
  
  <p>The easiest way that I discovered to make it support port numbers was to make it parse a given URL first then work with it.</p>
  
  <pre><code>        private void postData(String value_id,String  value_seaction,
          String value_item,
          String value_descration) {
  
          HttpParams httpParameters = new BasicHttpParams();
          HttpProtocolParams.setContentCharset(httpParameters, HTTP.UTF_8);
          HttpProtocolParams.setHttpElementCharset(httpParameters, HTTP.UTF_8);
  
             HttpClient httpclient = new DefaultHttpClient(httpParameters);
            // Log.d("url=&gt;",value_item);
            // Log.d("url=&gt;","http://rafsanjan.uni-azad.ebrahiminezhad.ir/json/darkhasr.php?shdaneshjo="+value_id+"&amp;moavenat="+value_seaction+"&amp;darkhast="+value_item+"&amp;startdate=test&amp;tozih="+ value_descration);
          //   http://app.sirmagid.ac.ir:1180/json2
             Uri.Builder builder = new Uri.Builder();
             builder.scheme("http")
                 .authority("app.iaurafsanjan.ac.ir:1180")
                 .appendPath("json2")
                 .appendPath("darkhasr.php")
                 .appendQueryParameter("shdaneshjo", value_id)
                 .appendQueryParameter("moavenat", value_seaction)
                  .appendQueryParameter("darkhast", value_item)
                   .appendQueryParameter("startdatet", "0")
                   .appendQueryParameter("tozih", value_descration);
                // .fragment("section-name");
             String myUrl = builder.build().toString();
             Log.d("url=&gt;",myUrl);
  
            HttpPost httppost = new HttpPost(myUrl);
            // HttpPost httppost = new HttpPost
             ("http://sirmagid.uni-azad.ebrahiminezhad.ir   /json/darkhasr.php?shdaneshjo="+value_id+"&amp;moavenat="+value_seaction+"&amp;darkhast="+zir_item+"&amp;startdate=test&amp;tozih="+ value_descration);  //???
             try {
                 ArrayList&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;(8);
                 //nameValuePairs.add(new BasicNameValuePair("name", name));
                 httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs,"UTF-8"));
                 HttpResponse response = httpclient.execute(httppost);
                 HttpEntity resEntity = response.getEntity();  
                 Log.d("RESPONSE",EntityUtils.toString(resEntity));
  
             }
             catch(Exception e)
             {
                 Log.e("log_tag", "Error:  "+e.toString());
             }
         }
  </code></pre>
  
  <p>return:</p>
  
  <p><code>http://app.sirmagid.ac.ir%3a1180/json2/darkhasr?shdaneshjo=920275234&amp;moavenat=%D8%A7%D9%85%D9%88%D8%B2%D8%B4%DB%8C&amp;darkhast=j&amp;startdatet=0&amp;tozih=66666</code></p>
  
  <p>error:</p>
  
  <p><code>%3a1180/</code></p>