diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties
index c60fdf0b6..317d481f3 100644
--- a/android/gradle/wrapper/gradle-wrapper.properties
+++ b/android/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Sat Aug 12 07:48:35 CEST 2017
+#Fri Jun 01 10:33:07 BRT 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml
index 807904417..afa9020b2 100644
--- a/android/src/main/AndroidManifest.xml
+++ b/android/src/main/AndroidManifest.xml
@@ -1,9 +1,37 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
\ No newline at end of file
diff --git a/android/src/main/java/com/RNFetchBlob/RNFetchBlob.java b/android/src/main/java/com/RNFetchBlob/RNFetchBlob.java
index 64b0b4833..b6cf7013e 100644
--- a/android/src/main/java/com/RNFetchBlob/RNFetchBlob.java
+++ b/android/src/main/java/com/RNFetchBlob/RNFetchBlob.java
@@ -3,7 +3,10 @@
import android.app.Activity;
import android.app.DownloadManager;
import android.content.Intent;
+import android.content.pm.PackageManager;
import android.net.Uri;
+import android.os.Build;
+import android.support.v4.content.FileProvider;
import android.util.SparseArray;
import com.facebook.react.bridge.ActivityEventListener;
@@ -24,6 +27,7 @@
import okhttp3.OkHttpClient;
import okhttp3.JavaNetCookieJar;
+import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.LinkedBlockingQueue;
@@ -105,10 +109,29 @@ public void run() {
@ReactMethod
public void actionViewIntent(String path, String mime, final Promise promise) {
try {
- Intent intent= new Intent(Intent.ACTION_VIEW)
- .setDataAndType(Uri.parse("file://" + path), mime);
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- this.getReactApplicationContext().startActivity(intent);
+ Uri uriForFile = FileProvider.getUriForFile(getCurrentActivity(),
+ this.getReactApplicationContext().getPackageName() + ".provider", new File(path));
+
+ if (Build.VERSION.SDK_INT >= 24) {
+ // Create the intent with data and type
+ Intent intent = new Intent(Intent.ACTION_VIEW)
+ .setDataAndType(uriForFile, mime);
+
+ // Set flag to give temporary permission to external app to use FileProvider
+ intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
+
+ // Validate that the device can open the file
+ PackageManager pm = getCurrentActivity().getPackageManager();
+ if (intent.resolveActivity(pm) != null) {
+ this.getReactApplicationContext().startActivity(intent);
+ }
+
+ } else {
+ Intent intent = new Intent(Intent.ACTION_VIEW)
+ .setDataAndType(Uri.parse("file://" + path), mime).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+
+ this.getReactApplicationContext().startActivity(intent);
+ }
ActionViewVisible = true;
final LifecycleEventListener listener = new LifecycleEventListener() {
@@ -382,4 +405,4 @@ public void getSDCardDir(Promise promise) {
public void getSDCardApplicationDir(Promise promise) {
RNFetchBlobFS.getSDCardApplicationDir(this.getReactApplicationContext(), promise);
}
-}
+}
\ No newline at end of file
diff --git a/android/src/main/res/xml/provider_paths.xml b/android/src/main/res/xml/provider_paths.xml
new file mode 100644
index 000000000..1434ff0ad
--- /dev/null
+++ b/android/src/main/res/xml/provider_paths.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
\ No newline at end of file