0
0
Fork 0
mirror of https://github.com/YTVanced/VancedManager synced 2024-11-29 14:33:01 +00:00

fixed uri parsing

This commit is contained in:
X1nto 2020-07-02 19:11:57 +04:00
parent 12a1deb368
commit bd562c1df3

View file

@ -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)