check if any app is capable of opening clicked files
This commit is contained in:
parent
c8ce4ecb60
commit
d02c007e45
1 changed files with 6 additions and 1 deletions
|
@ -2,6 +2,7 @@ package com.simplemobiletools.filemanager.extensions
|
|||
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import com.simplemobiletools.commons.R
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.filemanager.BuildConfig
|
||||
import java.util.*
|
||||
|
@ -17,7 +18,11 @@ fun Activity.tryOpenPathIntent(path: String, forceChooser: Boolean) {
|
|||
action = Intent.ACTION_VIEW
|
||||
setDataAndType(uri, getMimeTypeFromUri(uri))
|
||||
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
|
||||
startActivity(this)
|
||||
if (resolveActivity(packageManager) != null) {
|
||||
startActivity(this)
|
||||
} else {
|
||||
toast(R.string.no_app_found)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
openPath(path, forceChooser)
|
||||
|
|
Loading…
Reference in a new issue