【发布时间】:2012-04-29 04:49:38
【问题描述】:
我向我的 servlet 发出请求
尝试 { Log.d(Constants.DEBUG_TAG_MAPS, "try"); HttpEntity 实体 = 新 StringEntity(json); post.setEntity(实体); 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 状态码:"+response.getStatusLine().getStatusCode()); if(response.getStatusLine().getStatusCode() == 200){ Log.d(Constants.DEBUG_TAG_MAPS, "响应 200"); HttpEntity responseEntity = response.getEntity(); if (responseEntity!= null) { Gson g = 新 Gson(); InputStream 是 = responseEntity.getContent(); InputStreamReader isr = new InputStreamReader(is); BufferedReader reader = new BufferedReader(isr); 尝试{ responseEntity.getContent(); 字符串 x = EntityUtils.toString(responseEntity); }catch(异常 e){ // TODO: 处理异常 } responseJSONObject = g.fromJson(reader, JSONResponseObject.class); Log.d(Constants.DEBUG_TAG_MAPS_console, responseJSONObject.toString()); reader.close(); System.gc(); } } } 捕捉(异常 e){ e.printStackTrace(); } /代码>上线:
InputStream 是 = responseEntity.getContent();
应用程序崩溃...响应代码为 200 ... 我查看了我的 tomcat 日志,一切正常。 JSONResponseObject 填充了值并发送。
可能是什么问题?如何获取到 logcat 的堆栈跟踪?
一个可能相关的问题: 我很清楚logcat中的“无法连接工厂客户端” 任何可能导致该问题的事情都不是我的情况
- api 密钥正确,debug.keystore 路径更正
- 清单中的所有权限
- uses-library android:name="com.google.android.maps 也在清单中
地图显示正确,缩放/移动时刷新。
【问题讨论】:
-
stacktrace 应该在 logcat 中。可能是“System.err”作为日志标签。 +
entity != null应该检查responseEntity -
它是如何崩溃的? Logcat 中必须有一些异常堆栈跟踪。请发布异常堆栈跟踪。
标签: android google-maps httpclient