我正在寻找有关如何在 android 上使用 HttpPost 方法发送信息的信息,但我总是看到:
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(posturl);
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("Name","Var1"));
params.add(new BasicNameValuePair("Name2","Var2"));
httppost.setEntity(new UrlEncodedFormEntity(params));
HttpResponse resp = httpclient.execute(httppost);
HttpEntity ent = resp.getEntity();
问题是我不能这样做,因为我必须连接到接收 XML 格式的字符串的资源。
关于如何在不使用字符串的情况下仅发送字符串的任何想法List<nameValuePair>