Commit ed5811af authored by Sebastian Kaspari's avatar Sebastian Kaspari
Browse files

AbstractFetchDownloadService: Remove notifications when task gets removed.

parent af942d90
......@@ -185,8 +185,22 @@ abstract class AbstractFetchDownloadService : Service() {
return super.onStartCommand(intent, flags, startId)
}
override fun onTaskRemoved(rootIntent: Intent?) {
// If the task gets removed (app gets swiped away in the task switcher) our process and this
// servies gets killed. In this situation we remove the notification since the download will
// stop and cannot be controlled via the notification anymore (until we persist enough data
// to resume downloads from a new process).
val notificationManager = NotificationManagerCompat.from(this)
downloadJobs.values.forEach { state ->
notificationManager.cancel(state.foregroundServiceId)
}
}
override fun onDestroy() {
super.onDestroy()
downloadJobs.values.forEach {
it.job?.cancel()
}
......
Supports Markdown
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