check if any app is capable of opening clicked files

This commit is contained in:
tibbi 2018-02-18 09:07:47 +01:00
parent c8ce4ecb60
commit d02c007e45

View file

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