title: Application closes after taking picture on some devices
body: <p>My app crash after taking picture on Samsung Galaxy Grand Prime Pro but work on other devices. I have tried to figure out why it could be so but just couldn't figure it out.</p>
  
  <p>The video recording worked fine but don't know why picture is giving error.</p>
  
  <p>This is what happened when taking picture:</p>
  
  <p>When camera lunched and picture taken, when I clicked on <strong>Ok</strong> an error prompt out  saying <strong>Appname has stopped</strong></p>
  
  <p>Video is working well but when I snap picture and click ok to return it gives error.</p>
  
  <p>below is my code for capturing image and video</p>
  
  <pre><code>  public void onActivityResult(int requestCode, int resultCode, Intent data) {
              if (resultCode == Activity.RESULT_OK) {
                  if (requestCode == TAKE_PICTURE) {
                      capturedImageUri = data.getData();
  
                      if (!hasPermissions(this, PERMISSIONS)){
                          ActivityCompat.requestPermissions(this, PERMISSIONS, PERMISSION_ALL);
                      }else {
                          mediaFile = "";
                          mediaFile = getRealPathFromURIPath(capturedImageUri, EventActivity.this);
                          Log.d(TAG, "Capture image path" + mediaFile);
                          attachmentStatus.setText("Image file has been attached");
                          isImage = true;
                      }
                  }
                  if (requestCode == REQUEST_VIDEO_CAPTURE) {
                      videoUri = data.getData();
  
                      if (!hasPermissions(this, PERMISSIONS)){
                          ActivityCompat.requestPermissions(this, PERMISSIONS, PERMISSION_ALL);
                      }else{
                          videoFile = getRealPathFromURIPath(videoUri, EventActivity.this);
                          Log.d(TAG, "Captured video path " + videoUri);
                          Log.d(TAG, "New path " + videoFile);
                          attachmentStatus.setText("Video file has been attached");
                          isImage = false;
                      }
                  }
              }
          }
  
   private void showOptionDialog(){
          final Dialog dialog = new Dialog(EventActivity.this);
          dialog.setTitle("SELECT ACTION TO COMPLETE");
          dialog.setContentView(R.layout.image_video_layout);
  
          final TextView takePhoto = (TextView)dialog.findViewById(R.id.take_photo);
          final TextView recordVideo = (TextView)dialog.findViewById(R.id.record_video);
  
          dialog.show();
  
          takePhoto.setOnClickListener(new View.OnClickListener() {
  
              @Override
              public void onClick(View view) {
                  Log.d(TAG, "Take a picture");
                  if(isLocationEnabled()){
                      Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                      startActivityForResult(intent, TAKE_PICTURE);
                  }else{
                      showLocationAlert();
                  }
                  dialog.dismiss();
              }
          });
  
          recordVideo.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  Log.d(TAG, "Record a video");
                  Intent videoCaptureIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
                  if(videoCaptureIntent.resolveActivity(getPackageManager()) != null){
                      startActivityForResult(videoCaptureIntent, REQUEST_VIDEO_CAPTURE);
                  }
                  dialog.dismiss();
              }
          });
      }
  </code></pre>