From bd562c1df3dd8ad7bf52b466649c39bc57dfe6bb Mon Sep 17 00:00:00 2001 From: X1nto Date: Thu, 2 Jul 2020 19:11:57 +0400 Subject: [PATCH] fixed uri parsing --- .../vanced/manager/ui/fragments/UpdateCheckFragment.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/vanced/manager/ui/fragments/UpdateCheckFragment.kt b/app/src/main/java/com/vanced/manager/ui/fragments/UpdateCheckFragment.kt index 9254cabe..7030fe1f 100644 --- a/app/src/main/java/com/vanced/manager/ui/fragments/UpdateCheckFragment.kt +++ b/app/src/main/java/com/vanced/manager/ui/fragments/UpdateCheckFragment.kt @@ -4,6 +4,7 @@ import android.content.Intent import android.graphics.Color import android.graphics.drawable.ColorDrawable import android.net.Uri +import android.os.Build import android.os.Bundle import android.util.Log import android.view.LayoutInflater @@ -13,6 +14,7 @@ import android.widget.Button import android.widget.ProgressBar import android.widget.TextView import android.widget.Toast +import androidx.core.content.FileProvider import androidx.fragment.app.DialogFragment import com.dezlum.codelabs.getjson.GetJson import com.downloader.Error @@ -76,7 +78,13 @@ class UpdateCheckFragment : DialogFragment() { .start(object : OnDownloadListener{ override fun onDownloadComplete() { activity?.let { - val uri = Uri.fromFile(File(activity!!.filesDir.path, "manager.apk")) + val apk = File(activity!!.filesDir.path, "manager.apk") + val uri = + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) + FileProvider.getUriForFile(activity!!, "${activity!!.packageName}.provider", apk) + else + Uri.fromFile(apk) + val intent = Intent(Intent.ACTION_VIEW) intent.setDataAndType(uri, "application/vnd.android.package-archive") startActivity(intent)