我是Android的新手,我开始使用JSON并且不知道为什么他们使用HTTP等,
怀疑1:我很困惑,因为有时他们使用DefaultHttpClient,有时他们使用Httpclient
怀疑2: 我看到两种语法用于相同的操作 BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream," UTF-8"),8);BufferedReader reader = new BufferedReader(new InputStreamReader(inputstream));
对此的任何其他说明对我也有帮助
答案 0 :(得分:0)
bufferreader是将响应转换为String,这行
BufferedReader reader = new BufferedReader(new InputStreamReader(inputstream));
更好地使用响应处理程序是将响应直接转换为字符串。
ResponseHandler<String> responseHandler = new BasicResponseHandler();
String responseBody = httpclient.execute(httppost,responseHandler);
答案 1 :(得分:0)
请参阅这两个链接 Json Paring: http://www.androidhive.info/2012/01/android-json-parsing-tutorial/
Http客户端 http://developer.android.com/reference/org/apache/http/client/HttpClient.html
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream,&#34; UTF-8&#34;),8); &#34; UTF-8&#34;表示从接收的字符串编码