[Android] Keep services foreground on Oreo
Geoffrey Métais
git at videolan.org
Fri Oct 6 12:13:58 CEST 2017
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Oct 6 12:12:41 2017 +0200| [0bce7f118732850ef6eba92bfd949b377e5611fa] | committer: Geoffrey Métais
Keep services foreground on Oreo
> https://code.videolan.org/videolan/vlc-android/commit/0bce7f118732850ef6eba92bfd949b377e5611fa
---
vlc-android/src/org/videolan/vlc/MediaParsingService.java | 2 ++
vlc-android/src/org/videolan/vlc/PlaybackService.java | 4 +---
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/MediaParsingService.java b/vlc-android/src/org/videolan/vlc/MediaParsingService.java
index 9e2e0322b..a97f07019 100644
--- a/vlc-android/src/org/videolan/vlc/MediaParsingService.java
+++ b/vlc-android/src/org/videolan/vlc/MediaParsingService.java
@@ -127,6 +127,8 @@ public class MediaParsingService extends Service implements DevicesDiscoveryCb {
// Except for Android 8+ which expects startForeground immediately
if (mLastNotificationTime <= 0L)
mLastNotificationTime = AndroidUtil.isOOrLater ? 0L : System.currentTimeMillis();
+ if (AndroidUtil.isOOrLater)
+ showNotification();
}
switch (intent.getAction()) {
case ACTION_INIT:
diff --git a/vlc-android/src/org/videolan/vlc/PlaybackService.java b/vlc-android/src/org/videolan/vlc/PlaybackService.java
index b922cb7cd..e071dec0d 100644
--- a/vlc-android/src/org/videolan/vlc/PlaybackService.java
+++ b/vlc-android/src/org/videolan/vlc/PlaybackService.java
@@ -323,8 +323,6 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
- if (AndroidUtil.isOOrLater)
- showNotification();
if (intent == null)
return START_STICKY;
final String action = intent.getAction();
@@ -969,7 +967,7 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
cover, playing, sessionToken, getSessionPendingIntent());
if (isPlayingPopup())
return;
- if (!AndroidUtil.isLolliPopOrLater || playing)
+ if (AndroidUtil.isOOrLater || !AndroidUtil.isLolliPopOrLater || playing)
PlaybackService.this.startForeground(3, notification);
else {
PlaybackService.this.stopForeground(false);
More information about the Android
mailing list