我的ListView活动会在一段时间后自动关闭。我的ListView有一些TextView和图像来自解析,但在加载一些图像后,它会自动强制关闭... LogCat信息
06-25 16:29:31.238: W/SingleClientConnManager(706): Invalid use of SingleClientConnManager: connection still allocated.
06-25 16:29:31.238: W/SingleClientConnManager(706): Make sure to release the connection before allocating another one.
06-25 16:29:31.988: W/dalvikvm(706): threadid=11: thread exiting with uncaught exception (group=0x40015560)
06-25 16:29:32.098: E/AndroidRuntime(706): FATAL EXCEPTION: AsyncTask #3
06-25 16:29:32.098: E/AndroidRuntime(706): java.lang.RuntimeException: An error occured while executing doInBackground()
06-25 16:29:32.098: E/AndroidRuntime(706): at android.os.AsyncTask$3.done(AsyncTask.java:200)
06-25 16:29:32.098: E/AndroidRuntime(706): at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:274)
06-25 16:29:32.098: E/AndroidRuntime(706): at java.util.concurrent.FutureTask.setException(FutureTask.java:125)
06-25 16:29:32.098: E/AndroidRuntime(706): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:308)
06-25 16:29:32.098: E/AndroidRuntime(706): at java.util.concurrent.FutureTask.run(FutureTask.java:138)
06-25 16:29:32.098: E/AndroidRuntime(706): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
06-25 16:29:32.098: E/AndroidRuntime(706): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
06-25 16:29:32.098: E/AndroidRuntime(706): at java.lang.Thread.run(Thread.java:1019)
06-25 16:29:32.098: E/AndroidRuntime(706): Caused by: java.lang.IllegalStateException: No wrapped connection.
06-25 16:29:32.098: E/AndroidRuntime(706): at org.apache.http.impl.conn.AbstractClientConnAdapter.assertValid(AbstractClientConnAdapter.java:163)
06-25 16:29:32.098: E/AndroidRuntime(706): at org.apache.http.impl.conn.AbstractClientConnAdapter.getRemotePort(AbstractClientConnAdapter.java:314)
06-25 16:29:32.098: E/AndroidRuntime(706): at org.apache.http.client.protocol.RequestAddCookies.process(RequestAddCookies.java:137)
06-25 16:29:32.098: E/AndroidRuntime(706): at org.apache.http.protocol.BasicHttpProcessor.process(BasicHttpProcessor.java:290)
06-25 16:29:32.098: E/AndroidRuntime(706): at org.apache.http.protocol.HttpRequestExecutor.preProcess(HttpRequestExecutor.java:160)
06-25 16:29:32.098: E/AndroidRuntime(706): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:401)
06-25 16:29:32.098: E/AndroidRuntime(706): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
06-25 16:29:32.098: E/AndroidRuntime(706): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
06-25 16:29:32.098: E/AndroidRuntime(706): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
06-25 16:29:32.098: E/AndroidRuntime(706): at com.javacodegeeks.android.apps.moviesearchapp.services.HttpRetriever.retrieveStream(HttpRetriever.java:63)
06-25 16:29:32.098: E/AndroidRuntime(706): at com.javacodegeeks.android.apps.moviesearchapp.ui.UpcomingAdapter$BitmapDownloaderTask.doInBackground(UpcomingAdapter.java:133)
06-25 16:29:32.098: E/AndroidRuntime(706): at com.javacodegeeks.android.apps.moviesearchapp.ui.UpcomingAdapter$BitmapDownloaderTask.doInBackground(UpcomingAdapter.java:1)
06-25 16:29:32.098: E/AndroidRuntime(706): at android.os.AsyncTask$2.call(AsyncTask.java:185)
06-25 16:29:32.098: E/AndroidRuntime(706): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
06-25 16:29:32.098: E/AndroidRuntime(706): ... 4 more
06-25 16:29:34.928: D/dalvikvm(706): GC_FOR_MALLOC freed 1533K, 59% free 3051K/7367K, external 3067K/3245K, paused 2122ms
06-25 16:30:15.378: I/Process(706): Sending signal. PID: 706 SIG: 9
我的bitMapDownloaderTask是
private class BitmapDownloaderTask extends AsyncTask<String, Void, Bitmap> {
private String url;
private final WeakReference<ImageView> imageViewReference;
public BitmapDownloaderTask(ImageView imageView) {
imageViewReference = new WeakReference<ImageView>(imageView);
}
@Override
protected Bitmap doInBackground(String... params) {
url = params[0];
InputStream is = httpRetriever.retrieveStream(url);
if (is==null) {
return null;
}
return BitmapFactory.decodeStream(new FlushedInputStream(is));
}
@Override
protected void onPostExecute(Bitmap bitmap) {
if (isCancelled()) {
bitmap = null;
}
addBitmapToCache(url, bitmap);
if (imageViewReference != null) {
ImageView imageView = imageViewReference.get();
if (imageView != null) {
imageView.setImageBitmap(bitmap);
}
}
}
}
和我的httpRetriever.retrieveStream
public InputStream retrieveStream(String url) {
HttpGet getRequest = new HttpGet(url);
try {
HttpResponse getResponse = client.execute(getRequest);
final int statusCode = getResponse.getStatusLine().getStatusCode();
if (statusCode != HttpStatus.SC_OK) {
Log.w(getClass().getSimpleName(), "Error " + statusCode + " for URL " + url);
return null;
}
HttpEntity getResponseEntity = getResponse.getEntity();
return getResponseEntity.getContent();
}
catch (IOException e) {
getRequest.abort();
Log.w(getClass().getSimpleName(), "Error for URL " + url, e);
}
return null;
}
请帮忙......