Commit 72fc0170 authored by Geoffrey Métais's avatar Geoffrey Métais

Ensure notification channels are created on start

parent 5fe6f2a3
......@@ -23,6 +23,7 @@
package org.videolan.vlc
import android.annotation.SuppressLint
import android.annotation.TargetApi
import android.app.Service
import android.content.BroadcastReceiver
import android.content.Context
......@@ -30,6 +31,7 @@ import android.content.Intent
import android.content.IntentFilter
import android.net.Uri
import android.os.Binder
import android.os.Build
import android.os.IBinder
import android.os.PowerManager
import android.text.TextUtils
......@@ -137,8 +139,10 @@ class MediaParsingService : Service(), DevicesDiscoveryCb, CoroutineScope {
return Service.START_NOT_STICKY
}
@TargetApi(Build.VERSION_CODES.O)
private fun forceForeground() {
val notification = NotificationHelper.createScanNotification(applicationContext, getString(R.string.loading_medialibrary), false, scanPaused)
NotificationHelper.createNotificationChannels(applicationContext)
startForeground(43, notification)
}
......
......@@ -563,6 +563,7 @@ class PlaybackService : MediaBrowserServiceCompat(), CoroutineScope, LifecycleOw
return playlistManager.player.getVout()
}
@TargetApi(Build.VERSION_CODES.O)
private fun forceForeground() {
val ctx = this@PlaybackService
val stopped = playlistManager.player.playbackState == PlaybackStateCompat.STATE_STOPPED
......@@ -570,6 +571,7 @@ class PlaybackService : MediaBrowserServiceCompat(), CoroutineScope, LifecycleOw
else NotificationHelper.createPlaybackNotification(ctx,false,
ctx.resources.getString(R.string.loading), "", "",null,
false, true, mediaSession.sessionToken, sessionPendingIntent)
NotificationHelper.createNotificationChannels(ctx.applicationContext)
startForeground(3, notification)
isForeground = true
if (isVideoPlaying || AndroidDevices.showTvUi(this) || stopped) hideNotification(true)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment