2022-06-28 20:02:26 +05:30
|
|
|
package com.github.libretube.services
|
|
|
|
|
|
|
|
import android.app.NotificationManager
|
|
|
|
import android.app.Service
|
|
|
|
import android.content.Context
|
|
|
|
import android.content.Intent
|
|
|
|
import android.os.IBinder
|
|
|
|
import androidx.annotation.Nullable
|
2022-07-30 16:03:01 +05:30
|
|
|
import com.github.libretube.PLAYER_NOTIFICATION_ID
|
2022-06-28 20:02:26 +05:30
|
|
|
|
|
|
|
class ClosingService : Service() {
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
override fun onBind(intent: Intent?): IBinder? {
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
|
|
|
|
// Handle application closing
|
|
|
|
override fun onTaskRemoved(rootIntent: Intent?) {
|
|
|
|
super.onTaskRemoved(rootIntent)
|
|
|
|
|
2022-07-30 16:03:01 +05:30
|
|
|
// destroy the player notification when the app gets destroyed
|
2022-06-28 20:02:26 +05:30
|
|
|
val nManager = this.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
2022-07-30 16:03:01 +05:30
|
|
|
nManager.cancel(PLAYER_NOTIFICATION_ID)
|
2022-06-28 20:02:26 +05:30
|
|
|
|
|
|
|
// Destroy the service
|
|
|
|
stopSelf()
|
|
|
|
}
|
|
|
|
}
|