title: NullPointerException while calling AsyncTask
body: <p>hre is mycode to crop image by AsyncTask:</p>
  
  <pre><code>package com.mmbang.weather;
  
  import java.io.FileNotFoundException;
  import java.io.IOException;
  
  
  import android.app.Activity;
  import android.content.Context;
  import android.graphics.Bitmap;
  import android.net.Uri;
  import android.os.AsyncTask;
  import android.os.Message;
  import android.util.Log;
  import android.widget.ImageView;
  
  public class CameraImageAsyncTask extends AsyncTask&lt;Uri, ImageView, Bitmap&gt; {
  
      private Context context;
      private Uri uri;
      private Bitmap bmp = null;
      private LocalHandler handler;
      private int flag;
      private String newPath;
      private boolean isTooSmall = false;
      private Runnable runable;
  
      // private ImageView iv;
  
      public CameraImageAsyncTask(Context context, Uri uri, int flag, LocalHandler handler) {
          this.context = context;
          this.uri = uri;
          this.flag = flag;
          this.handler = handler;
      }
  
      public void setRunable(Runnable run) {
          runable = run;
      }
  
      @Override
      protected Bitmap doInBackground(Uri... params) {
  
          try {
              bmp = BitmapUtil.getLoadImage(context, uri);
              if (bmp != null) {
                  float scale = 1.0f;
                  if (flag == 1 &amp;&amp; bmp.getHeight() &lt; 160 &amp;&amp; bmp.getWidth() &lt; 160) {
                      scale = 1.3f;
                  } else if (bmp.getHeight() &gt; 800 &amp;&amp; bmp.getWidth() &gt; 800) {
                      scale = 0.7f;
                  }
                  Bitmap newBmp = BitmapUtil.scaleToNewBitmap(bmp, scale);
                  newPath = BitmapUtil.saveBitmapToJpgFile(newBmp, System.currentTimeMillis() + "");
                  // bmp.recycle();
                  return newBmp;
              }
          } catch (FileNotFoundException e) {
              e.printStackTrace();
              return null;
          } catch (IOException e) {
              e.printStackTrace();
              return null;
          }
          return null;
      }
  
      @Override
      protected void onPostExecute(Bitmap result) {
          super.onPostExecute(result);
          // this.iv.setImageBitmap(result);
          Message msg = new Message();
          BitmapItem bi = new BitmapItem();
          bi.bmp = result;
          bi.path = newPath;
          msg.what = flag;
          msg.obj = bi;
          msg.arg1 = (isTooSmall == true ? 1 : 0);
  
          Log.i("xxxxx",String.valueOf(msg.what));
          Log.i("yyy",bi.path);
  
          handler.sendMessage(msg);
          Activity activity = (Activity) context;
          if (runable != null) activity.runOnUiThread(runable);
      }
  
      @Override
      protected void onPreExecute() {
          super.onPreExecute();
      }
  
      @Override
      protected void onProgressUpdate(ImageView... values) {
  
          super.onProgressUpdate(values);
      }
  
  
  
      public class BitmapItem {
          public Bitmap bmp;
          public String path;
      }
  
  }
  </code></pre>
  
  <p>and i call it like this:</p>
  
  <pre><code>new CameraImageAsyncTask(this, Uri.fromFile(photoFile), 1, imageTaskHandle).execute();
  </code></pre>
  
  <p>by i got this exception:</p>
  
  <pre><code>06-19 16:17:18.979: E/AndroidRuntime(19184): java.lang.NullPointerException
  06-19 16:17:18.979: E/AndroidRuntime(19184):    at com.mmbang.weather.CameraImageAsyncTask.onPostExecute(CameraImageAsyncTask.java:86)
  06-19 16:17:18.979: E/AndroidRuntime(19184):    at com.mmbang.weather.CameraImageAsyncTask.onPostExecute(CameraImageAsyncTask.java:1)
  </code></pre>
  
  <p>Why does this happen? Thanks a lot</p>