catch some exceptions thrown at startActivityForResult
This commit is contained in:
parent
b0bdd457be
commit
d46a47635d
2 changed files with 43 additions and 7 deletions
|
@ -311,7 +311,12 @@ abstract class BaseSimpleActivity : AppCompatActivity() {
|
|||
if (isRPlus()) {
|
||||
putExtra(DocumentsContract.EXTRA_INITIAL_URI, createAndroidDataOrObbUri(checkedDocumentPath))
|
||||
}
|
||||
|
||||
try {
|
||||
startActivityForResult(this, requestCode)
|
||||
} catch (e: Exception) {
|
||||
showErrorToast(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -333,7 +338,12 @@ abstract class BaseSimpleActivity : AppCompatActivity() {
|
|||
} else {
|
||||
toast(R.string.wrong_root_selected)
|
||||
val intent = Intent(Intent.ACTION_OPEN_DOCUMENT_TREE)
|
||||
|
||||
try {
|
||||
startActivityForResult(intent, requestCode)
|
||||
} catch (e: Exception) {
|
||||
showErrorToast(e)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
funAfterSAFPermission?.invoke(false)
|
||||
|
@ -360,7 +370,12 @@ abstract class BaseSimpleActivity : AppCompatActivity() {
|
|||
} else {
|
||||
toast(R.string.wrong_root_selected_usb)
|
||||
val intent = Intent(Intent.ACTION_OPEN_DOCUMENT_TREE)
|
||||
|
||||
try {
|
||||
startActivityForResult(intent, requestCode)
|
||||
} catch (e: Exception) {
|
||||
showErrorToast(e)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
funAfterSAFPermission?.invoke(false)
|
||||
|
@ -800,7 +815,13 @@ abstract class BaseSimpleActivity : AppCompatActivity() {
|
|||
putExtra(Intent.EXTRA_TITLE, filename)
|
||||
addCategory(Intent.CATEGORY_OPENABLE)
|
||||
|
||||
try {
|
||||
startActivityForResult(this, SELECT_EXPORT_SETTINGS_FILE_INTENT)
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
toast(R.string.system_service_disabled, Toast.LENGTH_LONG)
|
||||
} catch (e: Exception) {
|
||||
showErrorToast(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
package com.simplemobiletools.commons.activities
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.ActivityNotFoundException
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.widget.Toast
|
||||
import com.simplemobiletools.commons.R
|
||||
import com.simplemobiletools.commons.adapters.ManageBlockedNumbersAdapter
|
||||
import com.simplemobiletools.commons.dialogs.AddBlockedNumberDialog
|
||||
|
@ -19,7 +21,6 @@ import com.simplemobiletools.commons.models.BlockedNumber
|
|||
import kotlinx.android.synthetic.main.activity_manage_blocked_numbers.*
|
||||
import java.io.FileOutputStream
|
||||
import java.io.OutputStream
|
||||
import java.util.*
|
||||
|
||||
class ManageBlockedNumbersActivity : BaseSimpleActivity(), RefreshRecyclerViewListener {
|
||||
private val PICK_IMPORT_SOURCE_INTENT = 11
|
||||
|
@ -101,7 +102,14 @@ class ManageBlockedNumbersActivity : BaseSimpleActivity(), RefreshRecyclerViewLi
|
|||
Intent(Intent.ACTION_GET_CONTENT).apply {
|
||||
addCategory(Intent.CATEGORY_OPENABLE)
|
||||
type = "text/plain"
|
||||
|
||||
try {
|
||||
startActivityForResult(this, PICK_IMPORT_SOURCE_INTENT)
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
toast(R.string.system_service_disabled, Toast.LENGTH_LONG)
|
||||
} catch (e: Exception) {
|
||||
showErrorToast(e)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
handlePermission(PERMISSION_READ_STORAGE) {
|
||||
|
@ -161,7 +169,14 @@ class ManageBlockedNumbersActivity : BaseSimpleActivity(), RefreshRecyclerViewLi
|
|||
type = "text/plain"
|
||||
putExtra(Intent.EXTRA_TITLE, file.name)
|
||||
addCategory(Intent.CATEGORY_OPENABLE)
|
||||
|
||||
try {
|
||||
startActivityForResult(this, PICK_EXPORT_FILE_INTENT)
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
toast(R.string.system_service_disabled, Toast.LENGTH_LONG)
|
||||
} catch (e: Exception) {
|
||||
showErrorToast(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue