Android taking picture with FileProvider
<p>I'm taking a picture on Android Nougat with FileProvider, that's my code</p>

<pre><code>&lt;provider
        android:name="android.support.v4.content.FileProvider"
        android:authorities="com.mypackage.fileprovider"
        android:exported="false"
        android:grantUriPermissions="true"&gt;
        &lt;meta-data
            android:name="android.support.FILE_PROVIDER_PATHS"
            android:resource="@xml/file_paths" /&gt;
&lt;/provider&gt;
</code></pre>

<p>file_paths.xml:</p>

<pre><code>&lt;paths&gt;
    &lt;files-path name="img" path="images/" /&gt;
&lt;/paths&gt;
</code></pre>

<p>Java:</p>

<pre><code> String fileName = "cameraOutput" + System.currentTimeMillis() + ".jpg";
 File imagePath = new File(getContext().getFilesDir(), "images");
 File file = new File(imagePath, fileName);
 Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);

 final Uri outputUri = FileProvider.getUriForFile(activity, "com.mypackage.fileprovider", file);
 cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, outputUri);
 getContext().grantUriPermission(
            "com.google.android.GoogleCamera",
            outputUri,
            Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION
 );
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            cameraIntent.setFlags(FLAG_GRANT_WRITE_URI_PERMISSION);
 activity.startActivityForResult(cameraIntent, ACTIVITY_REQUEST_CODE);
</code></pre>

<p>Camera activity starts, take picture successfully, but the Activity Result is not OK and the only thing I see in error logs is </p>

<p>CAM_StateSavePic: exception while saving result to URI: Optional.of(content://com.mypackage.fileprovider/img/cameraOutput1469383289530.jpg) 
FileNotFoundException: Is a directory</p>

<p><strong>EDIT</strong>
missed File#createNewFile();</p>