wrap the wallpaper setter in a try-catch block
This commit is contained in:
parent
25b31eb5a7
commit
277ded39ab
|
@ -72,10 +72,14 @@ fun Activity.shareMedia(media: List<Medium>) {
|
|||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue