Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,14 @@ class ForegroundService : Service() {
if (::foregroundServiceStatus.isInitialized) {
isCorrectlyStopped = foregroundServiceStatus.isCorrectlyStopped()
}
val allowAutoRestart = foregroundTaskOptions.allowAutoRestart
if (allowAutoRestart && !isCorrectlyStopped && !ForegroundServiceUtils.isSetStopWithTaskFlag(this)) {
Log.e(TAG, "The service will be restarted after 5 seconds because it wasn't properly stopped.")
RestartReceiver.setRestartAlarm(this, 5000)

// Safely handle auto-restart by checking if options are initialized.
if (::foregroundTaskOptions.isInitialized) {
val allowAutoRestart = foregroundTaskOptions.allowAutoRestart
if (allowAutoRestart && !isCorrectlyStopped && !ForegroundServiceUtils.isSetStopWithTaskFlag(this)) {
Log.e(TAG, "The service will be restarted after 5 seconds because it wasn't properly stopped.")
RestartReceiver.setRestartAlarm(this, 5000)
}
}
}

Expand Down