From 8e4b03a13b7363c718fa99ba661acd94f209eee1 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Tue, 20 Sep 2022 20:00:15 +0200 Subject: [PATCH] fix updater --- .../github/libretube/services/UpdateService.kt | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/github/libretube/services/UpdateService.kt b/app/src/main/java/com/github/libretube/services/UpdateService.kt index 76dab8b38..8b3e566de 100644 --- a/app/src/main/java/com/github/libretube/services/UpdateService.kt +++ b/app/src/main/java/com/github/libretube/services/UpdateService.kt @@ -58,12 +58,15 @@ class UpdateService : Service() { val id = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1) if (downloadId == id) { // install the apk after download finished - val installIntent = Intent(Intent.ACTION_VIEW) - installIntent.flags = Intent.FLAG_ACTIVITY_NEW_TASK - installIntent.setDataAndType( - Uri.fromFile(file), - downloadManager.getMimeTypeForDownloadedFile(downloadId) - ) + val installIntent = Intent(Intent.ACTION_VIEW).apply { + addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) + addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) + setDataAndType( + Uri.fromFile(file), + downloadManager.getMimeTypeForDownloadedFile(downloadId) + ) + } + try { startActivity(installIntent) } catch (e: Exception) {