RTEditor/src/main/java/com/onegravity/rteditor/media/choose/ImageChooserManager.java
private boolean takePicture() {
        try {
            // Create an image file name (must be in "public area" or the camera app might not be able to access the file)
            File imagePath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
            File imageFile = MediaUtils.createUniqueFile(imagePath, CAPTURED_IMAGE_TEMPLATE, false);
            imagePath.mkdirs();
            if (imagePath.exists() && imageFile.createNewFile()) {
                setOriginalFile(imageFile.getAbsolutePath());
                Uri uriForCamera;

                if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
                    // There are compatibility issues with FileProvider Uris on lower versions
                    uriForCamera = Uri.fromFile(imageFile);
                } else {
                    uriForCamera = FileProvider.getUriForFile(mActivity, "com.onegravity.rteditor.fileprovider", imageFile);
                }
                Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE)
                        .putExtra(MediaStore.EXTRA_OUTPUT, uriForCamera);
                startActivity(intent);
            } else {
                Toast.makeText(mActivity, "Can't take picture without an sdcard", Toast.LENGTH_SHORT).show();
                return false;
            }
        } catch (Exception e) {
            Log.e(getClass().getSimpleName(), e.getMessage(), e);
        }
        return true;
    }
private boolean takePicture() {
        try {
            // Create an image file name (must be in "public area" or the camera app might not be able to access the file)
            File imagePath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
            File imageFile = MediaUtils.createUniqueFile(imagePath, CAPTURED_IMAGE_TEMPLATE, false);
            imagePath.mkdirs();
            if (imagePath.exists() && imageFile.createNewFile()) {
                setOriginalFile(imageFile.getAbsolutePath());
                Uri uriForCamera;

                if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
                    // There are compatibility issues with FileProvider Uris on lower versions
                    uriForCamera = Uri.fromFile(imageFile);
                } else {
                    uriForCamera = FileProvider.getUriForFile(mActivity, "com.onegravity.rteditor.fileprovider", imageFile);
                }
                Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE)
                        .putExtra(MediaStore.EXTRA_OUTPUT, uriForCamera);
                startActivity(intent);
            } else {
                Toast.makeText(mActivity, "Can't take picture without an sdcard", Toast.LENGTH_SHORT).show();
                return false;
            }
        } catch (Exception e) {
            Log.e(getClass().getSimpleName(), e.getMessage(), e);
        }
        return true;
    }
TODO: on Android M we need to ask the WRITE_EXTERNAL_STORAGE permission explicitly