Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/217.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 阻止HTTP调用似乎超时了_Android_Http_Blocking - Fatal编程技术网

Android 阻止HTTP调用似乎超时了

Android 阻止HTTP调用似乎超时了,android,http,blocking,Android,Http,Blocking,我想对查询数据库的php文件发出一个阻塞调用。我希望它是阻塞的,而不是异步的,因为我不希望用户在调用成功与否之前显示任何内容 我运行下面的代码,它在response=httpclient.executehttpget处停止;在犯错误之前,先休息一两分钟。我看不出e项中有错误 任何人都知道这里发生了什么-我的php文件使用异步任务 public static String blockingHttpCallToUrl(String url) { String result="nothingR

我想对查询数据库的php文件发出一个阻塞调用。我希望它是阻塞的,而不是异步的,因为我不希望用户在调用成功与否之前显示任何内容

我运行下面的代码,它在response=httpclient.executehttpget处停止;在犯错误之前,先休息一两分钟。我看不出e项中有错误

任何人都知道这里发生了什么-我的php文件使用异步任务

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行中没有任何可识别的内容。