Android 如果为空,请检查webservice
我有一个网络服务,我想知道它是否是空的?? 我想知道怎么做。。如何发送请求并在文本视图中打印响应?? 我知道必须使用Android 如果为空,请检查webservice,android,Android,我有一个网络服务,我想知道它是否是空的?? 我想知道怎么做。。如何发送请求并在文本视图中打印响应?? 我知道必须使用HttpConnetion 但是我对这门课感到困惑 DefaultHttpClient httpClient=新的DefaultHttpClient(); HttpGet-httpPost=新的HttpGet(urlName) 返回真值?getAttributeCount返回一个int!是的,我知道,但是我使用了一个条件,如果返回0 setText True,那么getProper
HttpConnetion
但是我对这门课感到困惑 DefaultHttpClient httpClient=新的DefaultHttpClient(); HttpGet-httpPost=新的HttpGet(urlName)
返回真值?getAttributeCount返回一个int!是的,我知道,但是我使用了一个条件,如果返回0 setText True,那么getPropertyCount()呢?没有在xmlPullParser中定义!!我如何使用它??@mihail
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
inputStream = httpEntity.getContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"), 8);
StringBuilder stringBuilder = new StringBuilder();
String line = null;
if ((line = reader.readLine()) != null) {
stringBuilder.append(line + "\n");
Data.servContent=stringBuilder.toString();
}
line = reader.readLine();
inputStream.close();
} catch (UnsupportedEncodingException e) {
System.err.print("UnsupportedEncodingException: " + e);
} catch (ClientProtocolException e) {
System.err.print("ClientProtocolException: " + e);
} catch (IOException e) {
System.err.print("IOException: " + e);
} catch (Exception e) {
Log.e("Buffer Error", "Error converting result " + e.toString());
}