android httpclient请求,的Android HttpClient的请求,并处理与实体

try {

Log.d(Constants.DEBUG_TAG_MAPS, "try");

HttpEntity entity = new StringEntity(json);

post.setEntity(entity);

HttpParams httpParameters = new BasicHttpParams();

HttpConnectionParams.setConnectionTimeout(httpParameters, 15000);

HttpConnectionParams.setSoTimeout(httpParameters, 150000);

httpclient = new DefaultHttpClient(httpParameters);

BasicHttpResponse response = (BasicHttpResponse) httpclient.execute(post);

Log.d(Constants.DEBUG_TAG_MAPS, "http status code : "+response.getStatusLine().getStatusCode());

if(response.getStatusLine().getStatusCode() == 200){

Log.d(Constants.DEBUG_TAG_MAPS, "response 200");

HttpEntity responseEntity = response.getEntity();

if (responseEntity!= null) {

Gson g = new Gson();

InputStream is = responseEntity.getContent();

InputStreamReader isr = new InputStreamReader(is);

BufferedReader reader = new BufferedReader(isr);

try{

responseEntity.getContent();

String x = EntityUtils.toString(responseEntity);

}catch (Exception e) {

// TODO: handle exception

}

responseJSONObject = g.fromJson(reader, JSONResponseObject.class);

Log.d(Constants.DEBUG_TAG_MAPS_console, responseJSONObject.toString());

reader.close();

System.gc();

}

}

} catch (Exception e) {

e.printStackTrace();

}

/code>

和上行:

InputStream为= responseEntity.getContent();

应用程序正在崩溃...响应代码是200 ... 我看过我的tomcat日志,一切正常。 JSONResponseObject充满了值并发送。

可能是什么问题?我如何获得堆栈跟踪logcat?

一个可能相关的问题: 我已经清楚地知道“不能等连接工厂客户端”在logcat的 任何事情可能导致该问题没有我的情况下

API密钥是否正确,路径正确debug.keystore

清单中

所有权限使用库的android:在清单名称=“com.google.android.maps以及

地图显示正确,放大/移动时刷新。

+0

stacktrace应该在logcat中。可能是“System.err”作为日志标记。 +'entity!= null'应该检查'responseEntity' –

2012-04-17 19:56:02

+0

它是如何崩溃的? Logcat中必须存在一些异常堆栈跟踪。请发布异常堆栈跟踪。 –

2012-04-17 22:10:05

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值