在我的应用程序中,像这样使用 HttpPost 解析 json
`
HttpClient httpClient = new DefaultHttpClient();
HttpParams httpParameters = httpClient.getParams();
HttpConnectionParams.setTcpNoDelay(httpParameters, true);
HttpContext localContext = new BasicHttpContext();
String url="http://ashishva.comxa.com/getdata_shoplistl_f.php?route="+sroute+"&shop_type="+sshoptype;
HttpPost httpGet = new HttpPost(url);
HttpResponse response = httpClient.execute(httpGet, localContext);
BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()`
我的清单文件已正确设置为可以访问 Internet
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
我在浏览器中获取 json,但有时仅在我的 android 手机和模拟器中获取结果。为什么会这样?为什么有时会得到而不是迟到。
虽然我没有得到任何数据,但我得到了异常
"java.net.UnknownHostException: Unable to resolve host "ashishva.comxa.com": No address associated with hostname"