From 9bf65cd0dcc7279e5ee8268c036027cff628a968 Mon Sep 17 00:00:00 2001 From: sober Date: Wed, 5 Jun 2024 22:53:59 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E4=BF=AE=E5=A4=8D=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E5=8D=87=E7=BA=A7=E6=97=A0=E6=B3=95=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=AE=89=E8=A3=85apk?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/com/lizongying/mytv/UpdateWorker.kt | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/lizongying/mytv/UpdateWorker.kt b/app/src/main/java/com/lizongying/mytv/UpdateWorker.kt index 72221ad..4bc9182 100644 --- a/app/src/main/java/com/lizongying/mytv/UpdateWorker.kt +++ b/app/src/main/java/com/lizongying/mytv/UpdateWorker.kt @@ -123,16 +123,13 @@ class UpdateWorker(context: Context, params: WorkerParameters) : CoroutineWorker if (apkFile.exists()) { val apkUri: Uri = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { - FileProvider.getUriForFile(context, context.packageName + ".fileprovider", apkFile) - .apply { - Intent.FLAG_GRANT_READ_URI_PERMISSION - } + FileProvider.getUriForFile(context, "${context.packageName}.provider", apkFile) } else { Uri.parse("file://${apkFile.absolutePath}") -// Uri.fromFile(apkFile) } -// val apkUri = Uri.parse("file://$apkFile") + Log.i(TAG, "apkUri $apkUri") + val installIntent = Intent(Intent.ACTION_VIEW).apply { setDataAndType(apkUri, "application/vnd.android.package-archive") addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_ACTIVITY_NEW_TASK)