如何用post将xml文件发到网络上。求解。。
解决方案 »
- framework/base/media/java
- android surfaceview使slidingdrawer布局显示不完整?
- android 高难度UI设计问题!!!!
- Android NDK编译的问题
- ListView 能获得列表的ietm吗?
- 在XT800手机上调用SmsManager的发短信接口,如何选择C网 or G网
- 关于Android中的时间监听问题
- android ndk 环境配置~ 求教
- PullToRefresh里嵌入viewPager轮播图片
- 有谁知道用Android Studio如何调用VS2012的Web Service的接口
- android短信草稿箱草稿删除的问题
- 一个颜色替换的问题
Apache的HttpEntity接口有一个实现类FileEntity
用xml文件生成这个对象,然后HttpClient用post方式通信就好了
private HttpEntity httpEntity;
private HttpResponse httpResponse;
private HttpPost httpPost;
public void doPost(String url, String filePath)
{
try
{
httpClient = new DefaultHttpClient();
httpPost = new HttpPost(url);
httpEntity = new FileEntity(new File(""), "text/xml");
httpPost.setEntity(httpEntity);
httpResponse = httpClient.execute(httpPost);
} catch (Exception e)
{
} finally
{
httpClient.getConnectionManager().shutdown();
}
}大概就是这样了,httpResponse就是你得到的响应,根据情况再转类型吧
还有,new FileEntity的第二个参数是contentType,根据你实际上传的文件格式确定