Reattach the detached service notification when the app is swiped (if not playing) for it be removed with the application.

This commit is contained in:
Antoine POPINEAU 2020-07-11 12:58:25 +02:00
parent eb6b7a807b
commit b6b9e4c053
No known key found for this signature in database
GPG Key ID: A78AC64694F84063
1 changed files with 10 additions and 3 deletions

View File

@ -217,6 +217,16 @@ class PlayerService : Service() {
override fun onBind(intent: Intent?): IBinder? = null
override fun onTaskRemoved(rootIntent: Intent?) {
super.onTaskRemoved(rootIntent)
if (!player.playWhenReady) {
mediaControlsManager.updateNotification(queue.current(), false)
stopSelf()
}
}
@SuppressLint("NewApi")
override fun onDestroy() {
scope.cancel()
@ -243,9 +253,6 @@ class PlayerService : Service() {
setPlaybackState(false)
player.release()
stopForeground(true)
stopSelf()
super.onDestroy()
}