title: Android Application crash - Null Pointer Exception
body: <p>I'm developing a simple app which captures an image from camera and saves it to storage. I cannot figure out what is wrong here...when user takes a picture and accept it, the app crashes. </p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      this.imageView = (ImageView)this.findViewById(R.id.imageView1);
      Button photoButton = (Button) this.findViewById(R.id.button1);
      photoButton.setOnClickListener(new View.OnClickListener() {
  
          @Override
          public void onClick(View v) {
              Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); 
  
              try {
                  File f = createImageFile();
                  photoFile = Uri.fromFile(f);
              } catch (IOException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              }
              cameraIntent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT,
                      photoFile);
              startActivityForResult(cameraIntent, CAMERA_REQUEST); 
          }
      });
  
      Button saveButton = (Button) this.findViewById(R.id.button3);
      saveButton.setOnClickListener(new View.OnClickListener() {
  
          @Override
          public void onClick(View v) {
              Thread thread = new Thread(new Runnable(){
                  @Override
                  public void run() {
                      try {
                          save2Samba("hello", "kfir.txt");
                          //Your code goes here
                      } 
                      catch (Exception e) {
                          e.printStackTrace();
                      }
                  }
              });
  
              thread.start();
          }
      });
  }
  
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {  
      super.onActivityResult(requestCode, resultCode, data);
              if (requestCode == CAMERA_REQUEST &amp;&amp; resultCode == RESULT_OK) {  
                  Bitmap photo = (Bitmap) data.getExtras().get("data"); 
                  imageView.setImageBitmap(photo);
              }  
      }
  
      private File createImageFile() throws IOException {
      // Create an image file name
      String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
      String imageFileName = "JPEG_" + timeStamp + "_";
      File storageDir = Environment.getExternalStoragePublicDirectory(
              Environment.DIRECTORY_PICTURES);
      File image = File.createTempFile(
          imageFileName,  /* prefix */
          ".jpg",         /* suffix */
          storageDir      /* directory */
      );
  
      // Save a file: path for use with ACTION_VIEW intents
      mCurrentPhotoPath = "file:" + image.getAbsolutePath();
      return image;
  }
  </code></pre>
  
  <p>logcat says</p>
  
  <pre><code>12-29 18:01:20.893: E/AndroidRuntime(8026): java.lang.RuntimeException: Failure    delivering result ResultInfo{who=null, request=1888, result=-1, data=null} to activity {com.example.hofyam/com.example.hofyam.MainActivity}: java.lang.NullPointerException
  </code></pre>
  
  <p>Please help..I'm stuck. Thanks</p>