my code is this: Manifest:
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="${applicationId}.providers.FileProvider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/>
</provider>
</application>
Method to send a photo:
private void dispatchTakePictureIntent(String name) {
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
File photoFile;
photoFile = createImageFile(name);
if (photoFile != null) {
Uri photoURI = FileProvider.getUriForFile(getApplication().getApplicationContext(),
"com.example.pc_intel.photo.provider",
photoFile);
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
startActivityForResult(takePictureIntent, TAKE_PICTURE);
} else {
Log.wtf("photoFile", "photoFile null");
}
} else {
Log.wtf("TakePicture", "resolve acivity null");
}
}
XML where the path is
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path name="external_files" path="imagenesFotoA"/>
</paths>