0
我使用以下代碼來調用android中的Web服務。在Android 4及更高版本中調用Web服務時出錯
if(requestType.equals("GET"))
{
try
{
// GET
HttpGet request = new HttpGet();
request.setURI(new URI(requestURL));
HttpResponse response = client.execute(request);
if(response == null)
{
Log.d(APP_NAME, "Get Response returned null");
}
else
{
HttpEntity entity = response.getEntity();
String encoding = EntityUtils.getContentCharSet(entity);
responseString = EntityUtils.toString(entity, encoding == null ? "UTF-8" : encoding);
}
}
catch(Exception e)
{
Log.e(APP_NAME, "Error Get : " + e.getMessage());
}
}
此代碼支持upto 3.0。但在Android 4.0及以上版本中不支持。 請做必要的。
郵政logcat的也。 – 2013-02-09 07:19:24