Skip to content

Commit 1ce6ece

Browse files
committed
Fix error toast crash
1 parent 52a73d4 commit 1ce6ece

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

app/src/main/java/org/schabi/newpipe/error/ErrorUtil.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import android.widget.Toast
1010
import androidx.core.app.NotificationCompat
1111
import androidx.core.app.NotificationManagerCompat
1212
import androidx.core.app.PendingIntentCompat
13+
import androidx.core.content.ContextCompat
1314
import androidx.fragment.app.Fragment
1415
import androidx.preference.PreferenceManager
1516
import com.google.android.material.snackbar.Snackbar
@@ -136,9 +137,11 @@ class ErrorUtil {
136137
NotificationManagerCompat.from(context)
137138
.notify(ERROR_REPORT_NOTIFICATION_ID, notificationBuilder.build())
138139

139-
// since the notification is silent, also show a toast, otherwise the user is confused
140-
Toast.makeText(context, R.string.error_report_notification_toast, Toast.LENGTH_SHORT)
141-
.show()
140+
ContextCompat.getMainExecutor(context).execute {
141+
// since the notification is silent, also show a toast, otherwise the user is confused
142+
Toast.makeText(context, R.string.error_report_notification_toast, Toast.LENGTH_SHORT)
143+
.show()
144+
}
142145
}
143146

144147
private fun getErrorActivityIntent(context: Context, errorInfo: ErrorInfo): Intent {

0 commit comments

Comments
 (0)