title: thread exiting with uncaught exception (group=0x41465700)
body: <p>I am trying to load images to my android app from my server using <code>HttpURLConnection()</code>. but i am getting the above error. The code in which the error occurs is below. The <code>downloadBitmap</code> function is called from <code>doInBackground()</code> function. Thanks in advance.</p>
  
  <pre><code>private Bitmap downloadBitmap(String url) {
  
           Log.d("msg", "in download bitmap");
  
  
  
           HttpURLConnection urlConnection = null;
           try {
               Log.d("msg", url);
               URL uri = new URL(url);
               urlConnection = (HttpURLConnection) uri.openConnection();
               //urlConnection.setDoOutput(true);
               int statusCode = urlConnection.getResponseCode();
               Log.d("status",statusCode+"");
               if (statusCode != HttpStatus.SC_OK) {
                   Log.d("msg","returning null");
                   return null;
               }
  
               InputStream inputStream = urlConnection.getInputStream();
               if (inputStream != null) 
               {
                   Log.d("msg","in download if");
                   Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
                   return bitmap;
               }
  
  
           } catch (Exception e) {
               urlConnection.disconnect();
               Log.w("ImageDownloader", "Error downloading image from " + url);
           } finally {
               if (urlConnection != null) {
                   urlConnection.disconnect();
               }
           }
           return null;
       }
  </code></pre>
  
  <p>And some times i get another error with the following stack trace</p>
  
  <pre><code> 07-26 02:21:45.282: E/AndroidRuntime(1031): FATAL EXCEPTION: AsyncTask #2
   07-26 02:21:45.282: E/AndroidRuntime(1031): java.lang.RuntimeException: An error occured while executing doInBackground()
   07-26 02:21:45.282: E/AndroidRuntime(1031):    at android.os.AsyncTask$3.done(AsyncTask.java:299)
   07-26 02:21:45.282: E/AndroidRuntime(1031):    at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)
   07-26 02:21:45.282: E/AndroidRuntime(1031):    at java.util.concurrent.FutureTask.setException(FutureTask.java:219)
   07-26 02:21:45.282: E/AndroidRuntime(1031):    at java.util.concurrent.FutureTask.run(FutureTask.java:239)
   07-26 02:21:45.282: E/AndroidRuntime(1031):    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
   07-26 02:21:45.282: E/AndroidRuntime(1031):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
   07-26 02:21:45.282: E/AndroidRuntime(1031):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
   07-26 02:21:45.282: E/AndroidRuntime(1031):    at java.lang.Thread.run(Thread.java:841)
   07-26 02:21:45.282: E/AndroidRuntime(1031): Caused by: java.lang.NullPointerException
   07-26 02:21:45.282: E/AndroidRuntime(1031):    at com.example.listview.List$ImageDownloaderTask.downloadBitmap(List.java:464)
   07-26 02:21:45.282: E/AndroidRuntime(1031):    at com.example.listview.List$ImageDownloaderTask.doInBackground(List.java:372)
   07-26 02:21:45.282: E/AndroidRuntime(1031):    at com.example.listview.List$ImageDownloaderTask.doInBackground(List.java:1)
   07-26 02:21:45.282: E/AndroidRuntime(1031):    at android.os.AsyncTask$2.call(AsyncTask.java:287)
   07-26 02:21:45.282: E/AndroidRuntime(1031):    at java.util.concurrent.FutureTask.run(FutureTask.java:234)
   07-26 02:21:45.282: E/AndroidRuntime(1031):    ... 4 more
   07-26 02:21:45.371: W/dalvikvm(1031): threadid=13: thread exiting with uncaught exception (group=0x41465700)
   07-26 02:21:45.371: I/Process(1031): Sending signal. PID: 1031 SIG: 9
  </code></pre>