diff --git a/app/src/main/java/org/oxycblt/auxio/util/FrameworkUtil.kt b/app/src/main/java/org/oxycblt/auxio/util/FrameworkUtil.kt index 0b28cf743..be91e9a19 100644 --- a/app/src/main/java/org/oxycblt/auxio/util/FrameworkUtil.kt +++ b/app/src/main/java/org/oxycblt/auxio/util/FrameworkUtil.kt @@ -24,6 +24,7 @@ import android.content.Intent import android.content.pm.PackageManager import android.graphics.PointF import android.os.Build +import android.os.TransactionTooLargeException import android.view.View import android.view.WindowInsets import androidx.annotation.RequiresApi @@ -300,7 +301,15 @@ fun Context.share(songs: Collection) { mimeTypes.add(song.format.mimeType) } - builder.setType(mimeTypes.singleOrNull() ?: "audio/*").startChooser() + try { + builder.setType(mimeTypes.singleOrNull() ?: "audio/*").startChooser() + } catch (e: TransactionTooLargeException) { + L.e("Failed to share ${songs.size} songs: Too large") + showToast(R.string.err_share_too_large) + } catch (e: Exception) { + L.e("Failed to share ${songs.size} songs: $e") + showToast(R.string.err_share_failed) + } } /** diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c08afdf8d..3e0139d4f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -347,6 +347,8 @@ Music loading failed Unable to import a playlist from this file Unable to export the playlist to this file + This is too large to share + Unable to share this No app found that can handle this task This folder is not supported