Code example for URI

Methods: getHost, getPort

0
    AndroidHttpClient client = null;
 
    try { 
      Log.w("MmsSender", "Sending MMS1 of length: " + (mms != null ? mms.length : "null"));
      client                 = constructHttpClient(context, parameters);
      URI targetUrl          = new URI(parameters.getMmsc());
 
      if (Util.isEmpty(targetUrl.getHost()))
        throw new IOException("Invalid target host: " + targetUrl.getHost() + " , " + targetUrl);
 
      HttpHost target        = new HttpHost(targetUrl.getHost(), targetUrl.getPort(), HttpHost.DEFAULT_SCHEME_NAME);
      HttpPost request       = new HttpPost(parameters.getMmsc());
      ByteArrayEntity entity = new ByteArrayEntity(mms);
 
      entity.setContentType("application/vnd.wap.mms-message");
 
      request.setEntity(entity);
      request.setParams(client.getParams());
      request.addHeader("Accept", "*/*, application/vnd.wap.mms-message, application/vnd.wap.sic");
      request.addHeader("x-wap-profile", "http://www.google.com/oha/rdf/ua-profile-kila.xml");
      HttpResponse response = client.execute(target, request);