I got an error using HttpPost for sending an MMS in Android.
In the Logcat it says:
ERROR/Here(447): ---------Error---开发者_StackOverflow社区--Target host must not be null, or set in parameters.
My sample code:
String url = "myurl";
HttpClient httpClient = new DefaultHttpClient();
try {
    httpClient.getParams().setParameter(url, new Integer(90000)); // 90 second
    HttpPost post = new HttpPost(url);
    File SDCard = Environment.getExternalStorageDirectory();
    File file = new File(SDCard, "1.png");
    FileEntity entity;
    entity = new FileEntity(file,"binary/octet-stream");
    entity.setChunked(true);
    post.setEntity(entity);
    post.addHeader("Header", "UniqueName");
    Log.i("MMSHTTP","----post---------------"+post);
    HttpResponse response = httpClient.execute(post);
    if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
        Log.e("Here",
              "--------Error--------Response Status line code:" + response.getStatusLine());
    }
    else 
    {
        // Here every thing is fine.
    }
    HttpEntity resEntity = response.getEntity();
    if (resEntity == null) {
        Log.e("Here","---------Error No Response!!-----");
    }
} catch (Exception ex) {
    Log.e("Here","---------Error-----"+ex.getMessage());
    ex.printStackTrace();
} finally {
    httpClient.getConnectionManager().shutdown();
}
How do I fix the error?
The url you're specifying is in your sample code is:
String url = "myurl";
In order for HttpClient to be able to determine the host name, you're going to need to supply a valid url. Something along the lines of:
String url = "http://myurl.com/index";
Note: The 'http://' is important so that the appropriate protocol can be determined.
This guy had the same problem.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论