catch an exception at getting the export destination file

This commit is contained in:
tibbi 2020-07-07 14:57:46 +02:00
parent 61582c2c21
commit 94e9ecd4c6
1 changed files with 6 additions and 2 deletions

View File

@ -220,8 +220,12 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
if (requestCode == PICK_IMPORT_SOURCE_INTENT && resultCode == Activity.RESULT_OK && resultData != null && resultData.data != null) { if (requestCode == PICK_IMPORT_SOURCE_INTENT && resultCode == Activity.RESULT_OK && resultData != null && resultData.data != null) {
tryImportContactsFromFile(resultData.data!!) tryImportContactsFromFile(resultData.data!!)
} else if (requestCode == PICK_EXPORT_FILE_INTENT && resultCode == Activity.RESULT_OK && resultData != null && resultData.data != null) { } else if (requestCode == PICK_EXPORT_FILE_INTENT && resultCode == Activity.RESULT_OK && resultData != null && resultData.data != null) {
val outputStream = contentResolver.openOutputStream(resultData.data!!) try {
exportContactsTo(ignoredExportContactSources, outputStream) val outputStream = contentResolver.openOutputStream(resultData.data!!)
exportContactsTo(ignoredExportContactSources, outputStream)
} catch (e: Exception) {
showErrorToast(e)
}
} }
} }