mirror of
https://github.com/SimpleMobileTools/Simple-File-Manager.git
synced 2025-04-24 23:18:50 +02:00
generate proper file URI at clicking an APK file
This commit is contained in:
parent
5d3466b565
commit
a1772a4fd2
@ -2,9 +2,12 @@ package com.simplemobiletools.filemanager.extensions
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.support.v4.content.FileProvider
|
||||
import com.simplemobiletools.commons.R
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.filemanager.BuildConfig
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
|
||||
fun Activity.sharePaths(paths: ArrayList<String>) {
|
||||
@ -13,7 +16,12 @@ fun Activity.sharePaths(paths: ArrayList<String>) {
|
||||
|
||||
fun Activity.tryOpenPathIntent(path: String, forceChooser: Boolean) {
|
||||
if (!forceChooser && path.endsWith(".apk", true)) {
|
||||
val uri = getFinalUriFromPath(path, BuildConfig.APPLICATION_ID) ?: return
|
||||
val uri = if (isNougatPlus()) {
|
||||
FileProvider.getUriForFile(this, "${BuildConfig.APPLICATION_ID}.provider", File(path))
|
||||
} else {
|
||||
Uri.fromFile(File(path))
|
||||
}
|
||||
|
||||
Intent().apply {
|
||||
action = Intent.ACTION_VIEW
|
||||
setDataAndType(uri, getMimeTypeFromUri(uri))
|
||||
|
Loading…
x
Reference in New Issue
Block a user