From 366129eee255ecfd6f6f39b94222bda8c2dad08b Mon Sep 17 00:00:00 2001 From: Michael Zh Date: Tue, 24 Jun 2025 22:34:35 -0400 Subject: [PATCH] Fix error toast crash --- app/src/main/java/org/schabi/newpipe/error/ErrorUtil.kt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/error/ErrorUtil.kt b/app/src/main/java/org/schabi/newpipe/error/ErrorUtil.kt index 93dd8e522..e74711b88 100644 --- a/app/src/main/java/org/schabi/newpipe/error/ErrorUtil.kt +++ b/app/src/main/java/org/schabi/newpipe/error/ErrorUtil.kt @@ -10,6 +10,7 @@ import android.widget.Toast import androidx.core.app.NotificationCompat import androidx.core.app.NotificationManagerCompat import androidx.core.app.PendingIntentCompat +import androidx.core.content.ContextCompat import androidx.fragment.app.Fragment import androidx.preference.PreferenceManager import com.google.android.material.snackbar.Snackbar @@ -136,9 +137,11 @@ class ErrorUtil { NotificationManagerCompat.from(context) .notify(ERROR_REPORT_NOTIFICATION_ID, notificationBuilder.build()) - // since the notification is silent, also show a toast, otherwise the user is confused - Toast.makeText(context, R.string.error_report_notification_toast, Toast.LENGTH_SHORT) - .show() + ContextCompat.getMainExecutor(context).execute { + // since the notification is silent, also show a toast, otherwise the user is confused + Toast.makeText(context, R.string.error_report_notification_toast, Toast.LENGTH_SHORT) + .show() + } } private fun getErrorActivityIntent(context: Context, errorInfo: ErrorInfo): Intent {