Android 阻止HTTP调用似乎超时了
我想对查询数据库的php文件发出一个阻塞调用。我希望它是阻塞的,而不是异步的,因为我不希望用户在调用成功与否之前显示任何内容 我运行下面的代码,它在response=httpclient.executehttpget处停止;在犯错误之前,先休息一两分钟。我看不出e项中有错误 任何人都知道这里发生了什么-我的php文件使用异步任务Android 阻止HTTP调用似乎超时了,android,http,blocking,Android,Http,Blocking,我想对查询数据库的php文件发出一个阻塞调用。我希望它是阻塞的,而不是异步的,因为我不希望用户在调用成功与否之前显示任何内容 我运行下面的代码,它在response=httpclient.executehttpget处停止;在犯错误之前,先休息一两分钟。我看不出e项中有错误 任何人都知道这里发生了什么-我的php文件使用异步任务 public static String blockingHttpCallToUrl(String url) { String result="nothingR
public static String blockingHttpCallToUrl(String url)
{
String result="nothingReturned";
HttpClient httpclient = new DefaultHttpClient();
// Prepare a request object
HttpGet httpget = new HttpGet(url);
// Execute the request
HttpResponse response;
try {
response = httpclient.execute(httpget);
// Examine the response status
Log.i("Praeda", response.getStatusLine().toString());
// Get hold of the response entity
HttpEntity entity = response.getEntity();
// If the response does not enclose an entity, there is no need
// to worry about connection release
if (entity != null) {
// A Simple JSON Response Read
InputStream instream = entity.getContent();
result= convertStreamToString(instream);
// now you have the string representation of the HTML request
instream.close();
}
} catch (Exception e) {}
return result;
}
e、 getMessage什么都不说?把e.printStackTrace;也在里面,贴上日志。是的,我看不出这个e.printToStackTrace打印到哪里。我在调试模式下运行我的应用程序,查看“android”选项卡和“devices | logcat”,但在我点击issuee.getMessage上的断点后闪过的100行中没有任何可识别的内容。