解决方案 »
- com.android.camera.action.CROP 图片剪裁问题
- [Android 网络] ksoap2与webservice交互报错
- Google Map上放大缩小按钮位置怎么改?
- 请问,哪位知道哪里有可运行的android calendar(日程表)的源代码或者例子?
- android可以自由摆放控件位置吗?
- 【醒目】求助,怎么在一个listview的适配器中去刷新另一个listview
- listview拦截scrollview消息的问题
- 新手环境部署问题
- Logcat唯独不输出error的信息
- IndexOutOfBoundsException: setSpan (12 ... 12) ends beyond length 6
- Android 界面切换开关门动画求解
- 一个界面两个按钮弹出对话框 怎么做 小白求赐教!有自己写的代码求改正
if (response.getStatusLine().getStatusCode() == 200) { 是不是response.getStatusLine().getStatusCode()也会消耗掉content
把代码改成这样也可以
public InputStream sendXml(String uri, String xml) {
post = new HttpPost(uri);
InputStream is = null;
try {
StringEntity entity = new StringEntity(xml, ConstantValue.ENCODING);
post.setEntity(entity); HttpResponse response = client.execute(post); // // 200
// is = response.getEntity().getContent(); if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
HttpEntity entitys = response.getEntity();
if (entitys != null) {
is = entity.getContent();
}
}
} catch (Exception e) {
e.printStackTrace();
} return is; }
if (response.getStatusLine().getStatusCode() == 200) { 是不是response.getStatusLine().getStatusCode()也会消耗掉content好吧,问题解决了就好。。结贴吧。。
把代码改成这样也可以
public InputStream sendXml(String uri, String xml) {
post = new HttpPost(uri);
InputStream is = null;
try {
StringEntity entity = new StringEntity(xml, ConstantValue.ENCODING);
post.setEntity(entity); HttpResponse response = client.execute(post); // // 200
// is = response.getEntity().getContent(); if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
HttpEntity entitys = response.getEntity();
if (entitys != null) {
is = entity.getContent();
}
}
} catch (Exception e) {
e.printStackTrace();
} return is; }那就是说明response.getEntity();返回的是null啊,导致的报异常。