From 7d3d0999f3510dbf54a8a6f0f37c98058138c86a Mon Sep 17 00:00:00 2001 From: Bram van de Kerkhof Date: Tue, 25 Oct 2016 17:34:49 +0200 Subject: [PATCH] Fixed API 24 FileProvider error --- app/src/main/AndroidManifest.xml | 10 ++++++++++ .../reader/notification/ImageNotificationReceiver.kt | 6 ++++-- app/src/main/res/xml/provider_paths.xml | 4 ++++ 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 app/src/main/res/xml/provider_paths.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 379f290acb..b7d73c3e06 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -54,6 +54,16 @@ android:theme="@style/FilePickerTheme"> + + + + diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/notification/ImageNotificationReceiver.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/notification/ImageNotificationReceiver.kt index fc1348ce5f..2c2a83d4e3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/notification/ImageNotificationReceiver.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/notification/ImageNotificationReceiver.kt @@ -5,6 +5,7 @@ import android.content.BroadcastReceiver import android.content.Context import android.content.Intent import android.net.Uri +import android.support.v4.content.FileProvider import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.util.notificationManager import java.io.File @@ -61,8 +62,9 @@ class ImageNotificationReceiver : BroadcastReceiver() { private fun showImage(context: Context, path: String) { val intent = Intent().apply { action = Intent.ACTION_VIEW - flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_MULTIPLE_TASK - setDataAndType(Uri.parse("file://" + path), "image/*") + flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_MULTIPLE_TASK or Intent.FLAG_GRANT_READ_URI_PERMISSION + val uri = FileProvider.getUriForFile(context,"eu.kanade.tachiyomi.provider",File(path)) + setDataAndType(uri, "image/*") } context.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 0000000000..5817df3bcb --- /dev/null +++ b/app/src/main/res/xml/provider_paths.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file