Logcat打印“接口名称:null”在每个 DefaultHttpClient 执行方法调用期间
我多次联系 Web 服务以通过 HttpGet 和 DefaultHttpClient 获取 JSON 字符串。
...
DefaultHttpClient defaultHttpClient = new DefaultHttpClient();
HttpGet httpGet = new HttpGet(url);
HttpResponse httpResponse = (HttpResponse)defaultHttpClient.execute(httpGet);
HttpEntity httpEntity = httpResponse.getEntity();
...
我发现 LogCat 每次 HttpResponse httpResponse = (HttpResponse)defaultHttpClient.execute(httpGet); 都会使用标签 System.out 打印接口名称:null代码> 被执行。
我是否使用 HttpGet 正确建立了此 http 连接?有不同的方法吗?
如何创建此连接而不从 System.out 标记获取 interface name: null LogCat 消息?
I am contacting a web service multiple times to get a JSON String via HttpGet
and DefaultHttpClient
.
...
DefaultHttpClient defaultHttpClient = new DefaultHttpClient();
HttpGet httpGet = new HttpGet(url);
HttpResponse httpResponse = (HttpResponse)defaultHttpClient.execute(httpGet);
HttpEntity httpEntity = httpResponse.getEntity();
...
I find that LogCat is printing interface name: null with tag System.out for each time HttpResponse httpResponse = (HttpResponse)defaultHttpClient.execute(httpGet);
is executed.
Am i establishing this http connection properly with HttpGet
? Is there a different way?
How can i create this connection and not get interface name: null LogCat messages from the System.out tag?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用这些;
Use these;
您是否异步使用 DefaultHTTPClient ?我过去也遇到过类似的错误(Android 2.x),发现一旦我为 DefaultHTTPClient 创建了一个单例并将我的 Web 请求放入 AsyncTask 中,这个错误就消失了。
Are you using the DefaultHTTPClient Asynchronously? I had a similar error in the past (Android 2.x) and found once I made a singleton for the DefaultHTTPClient and put my web request inside an AsyncTask this error went away.