[Android] Services: Force foreground sooner

Geoffrey Métais git at videolan.org
Fri Apr 3 15:39:55 CEST 2020


vlc-android | branch: 3.2.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Apr  3 15:39:07 2020 +0200| [bfb90cbf9bcaaca10552810c5b7bc75f4f3c52cc] | committer: Geoffrey Métais

Services: Force foreground sooner

> https://code.videolan.org/videolan/vlc-android/commit/bfb90cbf9bcaaca10552810c5b7bc75f4f3c52cc
---

 vlc-android/src/org/videolan/vlc/MediaParsingService.kt | 1 +
 vlc-android/src/org/videolan/vlc/PlaybackService.kt     | 1 +
 2 files changed, 2 insertions(+)

diff --git a/vlc-android/src/org/videolan/vlc/MediaParsingService.kt b/vlc-android/src/org/videolan/vlc/MediaParsingService.kt
index e776597cb..5f40db19f 100644
--- a/vlc-android/src/org/videolan/vlc/MediaParsingService.kt
+++ b/vlc-android/src/org/videolan/vlc/MediaParsingService.kt
@@ -123,6 +123,7 @@ class MediaParsingService : Service(), DevicesDiscoveryCb, CoroutineScope, Lifec
     override fun onCreate() {
         dispatcher.onServicePreSuperOnCreate()
         super.onCreate()
+        if (AndroidUtil.isOOrLater) forceForeground()
         localBroadcastManager = LocalBroadcastManager.getInstance(this)
         medialibrary = AbstractMedialibrary.getInstance()
         medialibrary.addDeviceDiscoveryCb(this at MediaParsingService)
diff --git a/vlc-android/src/org/videolan/vlc/PlaybackService.kt b/vlc-android/src/org/videolan/vlc/PlaybackService.kt
index 58ce9b0cb..3440544ac 100644
--- a/vlc-android/src/org/videolan/vlc/PlaybackService.kt
+++ b/vlc-android/src/org/videolan/vlc/PlaybackService.kt
@@ -463,6 +463,7 @@ class PlaybackService : MediaBrowserServiceCompat(), CoroutineScope, LifecycleOw
 
         updateHasWidget()
         if (!this::mediaSession.isInitialized) initMediaSession()
+        if (AndroidUtil.isOOrLater && !isForeground) forceForeground()
 
         val filter = IntentFilter().apply {
             priority = Integer.MAX_VALUE



More information about the Android mailing list