Fixed API 24 FileProvider error

This commit is contained in:
Bram van de Kerkhof 2016-10-25 17:34:49 +02:00
parent 93f90b5a62
commit 7d3d0999f3
3 changed files with 18 additions and 2 deletions

View File

@ -54,6 +54,16 @@
android:theme="@style/FilePickerTheme"> android:theme="@style/FilePickerTheme">
</activity> </activity>
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="eu.kanade.tachiyomi.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/>
</provider>
<service android:name=".data.library.LibraryUpdateService" <service android:name=".data.library.LibraryUpdateService"
android:exported="false"/> android:exported="false"/>

View File

@ -5,6 +5,7 @@ import android.content.BroadcastReceiver
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.net.Uri import android.net.Uri
import android.support.v4.content.FileProvider
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.util.notificationManager import eu.kanade.tachiyomi.util.notificationManager
import java.io.File import java.io.File
@ -61,8 +62,9 @@ class ImageNotificationReceiver : BroadcastReceiver() {
private fun showImage(context: Context, path: String) { private fun showImage(context: Context, path: String) {
val intent = Intent().apply { val intent = Intent().apply {
action = Intent.ACTION_VIEW action = Intent.ACTION_VIEW
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_MULTIPLE_TASK flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_MULTIPLE_TASK or Intent.FLAG_GRANT_READ_URI_PERMISSION
setDataAndType(Uri.parse("file://" + path), "image/*") val uri = FileProvider.getUriForFile(context,"eu.kanade.tachiyomi.provider",File(path))
setDataAndType(uri, "image/*")
} }
context.startActivity(intent) context.startActivity(intent)
} }

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<paths>
<external-path name="pictures" path="Pictures" />
</paths>