中断的AsyncTask

时间:2014-03-10 11:36:12

标签: android android-asynctask

我有一个使用DefaultHttpClient()调用Web服务的AsyncTask。

如果执行因任何原因停止(即我正在调试并按“终止”),则下一次调用将导致“拒绝连接”或超时。

由doInBackground()中的函数调用的代码:

    String response = null;

    HttpClient httpClient = new DefaultHttpClient();
    HttpPost httpPost = new HttpPost(url);

    SoapEnvelope env = new SoapEnvelope();
    env.setServiceNamespace(nameSpace);
    env.setMethodName(methodName);
    env.setParams(params);

    StringEntity se = new StringEntity(env.serialize(), HTTP.UTF_8);
    se.setContentType("text/xml");
    httpPost.setEntity(se);

    HttpResponse httpResponse = httpClient.execute(httpPost);
    HttpEntity resEntity = httpResponse.getEntity();

它被卡在了

    HttpResponse httpResponse = httpClient.execute(httpPost);

重新启动应用不起作用。

如果我重新启动设备,它会再次运行。

为什么它会像这样?

0 个答案:

没有答案