解决方案 »
- 如何获得ListView中任意一项的View
- Android GPS位置获取 为什么总是不能运行??!!!
- tabHost之间的activity 怎么传值
- canvas背景文字
- 求助Android NDK: this system lacks kernel support for PPP.
- android Menu设定后,点击无反应也无错误提示,求解
- 实现一个按钮不是在xml文件中实现
- 求助:android动画顺序执行的问题
- HTML5,更高效地到达更多设备和用户
- Camera的回调函数onPreviewFrame
- 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啊,导致的报异常。