Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.chirag.RNMail">

<application>
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/>
</provider>
</application>
</manifest>
6 changes: 5 additions & 1 deletion android/src/main/java/com/chirag/RNMail/RNMailModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.text.Html;
import android.support.v4.content.FileProvider;

import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
Expand Down Expand Up @@ -89,7 +90,10 @@ public void mail(ReadableMap options, Callback callback) {
if (attachment.hasKey("path") && !attachment.isNull("path")) {
String path = attachment.getString("path");
File file = new File(path);
Uri p = Uri.fromFile(file);
Uri p = FileProvider.getUriForFile(
reactContext,
reactContext.getApplicationContext()
.getPackageName() + ".provider", file);
i.putExtra(Intent.EXTRA_STREAM, p);
}
}
Expand Down
4 changes: 4 additions & 0 deletions android/src/main/res/xml/provider_paths.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path name="external_files" path="."/>
</paths>