From 14e603607b43805db337d35d3109464d644d9aa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Baj=C3=A1ki?= <81427020+BajakiGabesz@users.noreply.github.com> Date: Thu, 16 Mar 2023 17:05:53 +0100 Subject: [PATCH] Update MediaBrowserService.cs Fixed issue which causes an instant crash when starting foreground process on Android Pie and maybe others too. --- .../Android/MediaSession/MediaBrowserService.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/MediaManager/Platforms/Android/MediaSession/MediaBrowserService.cs b/MediaManager/Platforms/Android/MediaSession/MediaBrowserService.cs index 99236a50..7cc96893 100644 --- a/MediaManager/Platforms/Android/MediaSession/MediaBrowserService.cs +++ b/MediaManager/Platforms/Android/MediaSession/MediaBrowserService.cs @@ -141,7 +141,14 @@ protected virtual void PrepareNotificationManager() if (ongoing && !IsForeground) { ContextCompat.StartForegroundService(ApplicationContext, new Intent(ApplicationContext, MediaBrowserManager.ServiceType)); - StartForeground(notificationId, notification, ForegroundService.TypeMediaPlayback); + if (Build.VERSION.SdkInt >= BuildVersionCodes.S) + { + StartForeground(notificationId, notification, ForegroundService.TypeMediaPlayback); + } + else + { + StartForeground(notificationId, notification); + } IsForeground = true; } }