diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 9948868..2115831 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -24,6 +24,15 @@
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/de/sebse/fuplanner/services/KVV/Download.java b/app/src/main/java/de/sebse/fuplanner/services/KVV/Download.java
index 8fcfb83..dab0fd3 100644
--- a/app/src/main/java/de/sebse/fuplanner/services/KVV/Download.java
+++ b/app/src/main/java/de/sebse/fuplanner/services/KVV/Download.java
@@ -15,6 +15,7 @@ import java.util.Arrays;
import androidx.annotation.Nullable;
import androidx.core.app.ActivityCompat;
+import androidx.core.content.FileProvider;
import de.sebse.fuplanner.MainActivity;
import de.sebse.fuplanner.R;
import de.sebse.fuplanner.services.KVV.types.Resource;
@@ -55,7 +56,7 @@ public class Download {
if (file.getModifiedDate() != 0) {
if (!message.isEmpty())
message += "\n";
- resources.getString(R.string.last_modified_on, UtilsDate.getModifiedDateTime(contextInterface.get(), file.getModifiedDate()));
+ message += resources.getString(R.string.last_modified_on, UtilsDate.getModifiedDateTime(contextInterface.get(), file.getModifiedDate()));
}
alertDialogBuilder
@@ -181,9 +182,17 @@ public class Download {
}
private void fileOpen(File url){
- Uri uri = Uri.fromFile(url);
- Intent intent = new Intent();//Intent.ACTION_VIEW
+ Uri uri = FileProvider.getUriForFile(contextInterface.get(), contextInterface.get().getApplicationContext().getPackageName() + ".my.provider", url);
+
+ Intent intent;
+ if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
+ intent = new Intent(Intent.ACTION_VIEW);
+ } else {
+ intent = new Intent();
+ }
+ intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
+ intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
// Check what kind of file you are trying to open, by comparing the url with extensions.
// When the if condition is matched, plugin sets the correct intent (mime) type,
// so Android knew what application to use to open the file
@@ -228,7 +237,6 @@ public class Download {
//so you can choose which application to use
intent.setDataAndType(uri, "*/*");
}
-
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
contextInterface.get().startActivity(intent);
diff --git a/app/src/main/res/xml/provider_paths.xml b/app/src/main/res/xml/provider_paths.xml
new file mode 100644
index 0000000..4495c28
--- /dev/null
+++ b/app/src/main/res/xml/provider_paths.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file