0
我有兩個活動,在啓動時都向我的服務器發出不同的http請求。 當我在它們之間來回切換時,響應開始有一些延遲,因爲它們在彼此之間排隊。Android:空默認HttpClient隊列
我想清空並中止這個連接,只保留最新的連接。
我試圖
httpClient.getConnectionManager().shutdown();
但它拋出
05-14 08:20:51.137 12627-12997/com.tesis.restapp E/AndroidRuntime﹕ FATAL EXCEPTION: AsyncTask #2
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:278)
at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
at java.util.concurrent.FutureTask.run(FutureTask.java:137)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
Caused by: java.lang.IllegalStateException: Manager is shut down.
at org.apache.http.impl.conn.SingleClientConnManager.assertStillUp(SingleClientConnManager.java:175)
at org.apache.http.impl.conn.SingleClientConnManager.getConnection(SingleClientConnManager.java:213)
at org.apache.http.impl.conn.SingleClientConnManager$1.getConnection(SingleClientConnManager.java:191)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:326)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:580)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:512)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:490)
at support.JSONParser.makeHttpRequest(JSONParser.java:96)
at fragments.MainFragment$FetchOrders.doInBackground(MainFragment.java:150)
at fragments.MainFragment$FetchOrders.doInBackground(MainFragment.java:129)
at android.os.AsyncTask$2.call(AsyncTask.java:264)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)...
任何其他的想法?謝謝
沒有得到你。你想同時開始兩個電話? –
我想只將隊列保持爲一個呼叫。當創建一個新的請求時,我希望應用程序中止以前的所有操作,並從此開始。 – feresr
你試過這個httpclient.getConnectionManager()。closeExpiredConnections(); –