From edaace5d949619cd0c8e152b85652fbd09607947 Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 12 Apr 2017 23:40:10 +0200 Subject: [PATCH] check if there is an available activity for handling open_document_tree intent --- .../com/simplemobiletools/commons/extensions/Activity.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Activity.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Activity.kt index e76f320dd..188b4ffc5 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Activity.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Activity.kt @@ -10,6 +10,7 @@ import android.view.View import android.view.WindowManager import android.view.inputmethod.InputMethodManager import android.widget.EditText +import com.simplemobiletools.commons.R import com.simplemobiletools.commons.activities.BaseSimpleActivity import com.simplemobiletools.commons.dialogs.DonateDialog import com.simplemobiletools.commons.dialogs.WhatsNewDialog @@ -41,7 +42,12 @@ fun Activity.isShowingSAFDialog(file: File, treeUri: String, requestCode: Int): if (resolveActivity(packageManager) == null) { type = "*/*" } - startActivityForResult(this, requestCode) + + if (resolveActivity(packageManager) != null) { + startActivityForResult(this, requestCode) + } else { + toast(R.string.unknown_error_occurred) + } } } }