title: App android crash when opening camera on samsung galaxy s4 mini
body: <p>i just want to ask you something that i can't find a solution.</p>
  
  <p>I have a samsung galaxy s4 mini and i'm trying to do something with the camera, and sometimes it crashes, but it doesn't give me any error.</p>
  
  <p>I got this code:</p>
  
  <pre><code> private void dispatchTakePictureIntent() {
  Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
   // Ensure that there's a camera activity to handle the intent
   if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
       // Create the File where the photo should go
       File photoFile = null;
       try {
           photoFile = createImageFile();
       } catch (IOException e) {
           e.printStackTrace();
       }
       // Continue only if the File was successfully created
       if (photoFile != null) {
           takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT,
                   Uri.fromFile(photoFile));
  
           startActivityForResult(takePictureIntent, REQUEST_TAKE_PHOTO);
       }
   }
  }
  
   private File createImageFile() throws IOException {
   // Create an image file name
   String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new    Date());
   String imageFileName = "JPEG_" + timeStamp + "_";
   String directory = "appname" + File.separator + "images";
   String path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) + File.separator + directory;
   File storageDir = new File(path);
   storageDir.mkdirs();
  
   File image = File.createTempFile(
       imageFileName, /* prefix */
       ".jpg", /* suffix */
       storageDir /* directory */
   );
  
   // Save a file: path for use with ACTION_VIEW intents
   mCurrentPhotoPath = image.getAbsolutePath();
   return image;
   }
  
  
  @Override
   protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
   if (requestCode == REQUEST_TAKE_PHOTO &amp;&amp; resultCode == RESULT_OK &amp;&amp; mCurrentPhotoPath != null) { 
  
    File file = new File(mCurrentPhotoPath);
    BitmapFactory.Options btmapOptions = new BitmapFactory.Options();
    Bitmap bm = BitmapFactory.decodeFile(file.getAbsolutePath(),
                  btmapOptions);
  
    Bitmap resizedBitmap = Bitmap.createScaledBitmap(bm,(int)(bm.getWidth()*0.6), (int)(bm.getHeight()*0.6), true);
  
    mUri = Uri.fromFile(file);
          sendPhoto(Constants.encodeTobase64(resizedBitmap));
   } else {
    runOnUiThread(new Runnable() {
  
  @Override
  public void run() {
   Toast.makeText(mContext, "Error", Toast.LENGTH_SHORT).show();
  }
     });
    }
   }
  </code></pre>
  
  <p>Sometimes, when the application is in the method createImageFile(), the var mCurrentPhotoPath always have value, but when the app is in the method onActivityResult(), sometimes this value is NULL and is when this fails. The application just get closed and i don't have any type of error. It's a little strange, because sometimes it works (i did like 15 consecutive and the 16 failed..) .</p>
  
  <p>The strangest thing is that when I try this app in another phone, it works so..there is any solution?</p>
  
  <p>Thank you all and sorry for being too annoying on this..</p>