diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt index 1f5128ffc..05e13b6ba 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt @@ -72,10 +72,14 @@ fun Activity.shareMedia(media: List) { } fun Activity.trySetAsWallpaper(file: File) { - var uri = Uri.fromFile(file) - if (!setAsWallpaper(uri, file)) { - uri = getFileContentUri(file) - setAsWallpaper(uri, file, false) + try { + var uri = Uri.fromFile(file) + if (!setAsWallpaper(uri, file)) { + uri = getFileContentUri(file) + setAsWallpaper(uri, file, false) + } + } catch (e: Exception) { + toast(R.string.unknown_error_occurred) } }