0

我试图实现从这里获得的图像异步任务:

http://schimpf.es/asynctask-for-image-download/

然后我尝试在我的代码中执行它,如下所示:

ImageView im1 = (ImageView) findViewById(R.id.image);
ImageDownloadTask imageD = new ImageDownloadTask(im1);
imageD.execute(e.mediumLabel);

然后我得到了这个错误:

06-19 15:22:23.480: E/AndroidRuntime(18376): FATAL EXCEPTION: AsyncTask #2
06-19 15:22:23.480: E/AndroidRuntime(18376): java.lang.RuntimeException: An error occured while executing doInBackground()
06-19 15:22:23.480: E/AndroidRuntime(18376):    at android.os.AsyncTask$3.done(AsyncTask.java:299)
06-19 15:22:23.480: E/AndroidRuntime(18376):    at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)
06-19 15:22:23.480: E/AndroidRuntime(18376):    at java.util.concurrent.FutureTask.setException(FutureTask.java:219)
06-19 15:22:23.480: E/AndroidRuntime(18376):    at java.util.concurrent.FutureTask.run(FutureTask.java:239)
06-19 15:22:23.480: E/AndroidRuntime(18376):    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
06-19 15:22:23.480: E/AndroidRuntime(18376):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
06-19 15:22:23.480: E/AndroidRuntime(18376):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
06-19 15:22:23.480: E/AndroidRuntime(18376):    at java.lang.Thread.run(Thread.java:856)
06-19 15:22:23.480: E/AndroidRuntime(18376): Caused by: java.lang.NullPointerException: println needs a message
06-19 15:22:23.480: E/AndroidRuntime(18376):    at android.util.Log.println_native(Native Method)
06-19 15:22:23.480: E/AndroidRuntime(18376):    at android.util.Log.e(Log.java:231)
06-19 15:22:23.480: E/AndroidRuntime(18376):    at com.example.beerportfoliopro.ImageDownloadTask.doInBackground(ImageDownloadTask.java:42)
06-19 15:22:23.480: E/AndroidRuntime(18376):    at com.example.beerportfoliopro.ImageDownloadTask.doInBackground(ImageDownloadTask.java:1)
06-19 15:22:23.480: E/AndroidRuntime(18376):    at android.os.AsyncTask$2.call(AsyncTask.java:287)
06-19 15:22:23.480: E/AndroidRuntime(18376):    at java.util.concurrent.FutureTask.run(FutureTask.java:234)
4

1 回答 1

3

当您调用您的日志记录时Log.e,您没有传递有效的字符串,其中之一为空。看ImageDownloadTask line 42

于 2013-06-19T20:53:25.583 回答