Android : How to write camera intent in android nougat

Try this its not the intent that create the problem once you take the picture and save to the sd card and getting back the uri is different in Nougat....

It is quite easy to implement FileProvider on your application. First you need to add a FileProvider tag in AndroidManifest.xml under tag like below: AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=""

And then create a provider_paths.xml file in xml folder under res folder. Folder may be needed to create if it doesn't exist.


<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="">
    <external-path name="external_files" path="."/>

Done! FileProvider is now declared and be ready to use.

The final step is to change the line of code below in

Uri photoURI = Uri.fromFile(createImageFile());


Uri photoURI = FileProvider.getUriForFile(MainActivity.this,
            BuildConfig.APPLICATION_ID + ".provider",

And .... done ! Your application should now work perfectly fine on any Android version including Android Nougat. Cheers !

Hey please follow this thread as a reference. It will show you how to use File Provider when you set your targetSDK as 24 and change following. In your private static Uri getImageFileUri() method

Change this line

return Uri.fromFile(image);


FileProvider.getUriForFile(context, context.getApplicationContext().getPackageName() + ".provider", createImageFile());

Hope this will help you to solve your issue.
For more go to - Setting Up File Sharing - Offical documentation