Skip to content

Commit 0dcf18c

Browse files
author
Jan Guegel
committed
catch ActivityNotFoundException with fallback of SecurityException
Signed-off-by: Jan Guegel <[email protected]>
1 parent 588a046 commit 0dcf18c

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

app/src/main/kotlin/org/fossify/filemanager/activities/SimpleActivity.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ import android.provider.Settings
77
import org.fossify.commons.activities.BaseSimpleActivity
88
import org.fossify.commons.dialogs.ConfirmationAdvancedDialog
99
import org.fossify.commons.extensions.hasPermission
10+
import android.net.Uri
1011
import org.fossify.commons.extensions.showErrorToast
1112
import org.fossify.commons.extensions.toast
1213
import org.fossify.commons.helpers.PERMISSION_WRITE_STORAGE
1314
import org.fossify.commons.helpers.isRPlus
1415
import org.fossify.filemanager.R
15-
import androidx.core.net.toUri
1616

1717
open class SimpleActivity : BaseSimpleActivity() {
1818
override fun getAppIconIDs() = arrayListOf(
@@ -82,13 +82,16 @@ open class SimpleActivity : BaseSimpleActivity() {
8282
try {
8383
val intent = Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION)
8484
intent.addCategory("android.intent.category.DEFAULT")
85-
"package:$packageName".toUri().also { intent.data = it }
85+
intent.data = Uri.parse("package:$packageName")
8686
startActivityForResult(intent, MANAGE_STORAGE_RC)
87-
} catch (e: Exception) {
88-
toast(R.string.no_storage_permissions)
87+
} catch (e: android.content.ActivityNotFoundException) {
88+
showErrorToast(e)
8989
val intent = Intent()
9090
intent.action = Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION
9191
startActivityForResult(intent, MANAGE_STORAGE_RC)
92+
} catch (e: SecurityException) {
93+
showErrorToast(e)
94+
finish()
9295
}
9396
} else {
9497
finish()

0 commit comments

Comments
 (0)