Skip to content

Commit 5a7fc06

Browse files
adil192Dev-hwang
authored andcommitted
Fix: Add onTimeout handler to android ForegroundService.kt
Might fix this: RemoteServiceException$ForegroundServiceDidNotStopInTimeException A foreground service of type dataSync did not stop within its timeout: ComponentInfo{com.example.myapp/com.pravera.flutter_foreground_task.service.ForegroundService}
1 parent 67da414 commit 5a7fc06

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

android/src/main/kotlin/com/pravera/flutter_foreground_task/service/ForegroundService.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,11 @@ class ForegroundService : Service() {
219219
}
220220
}
221221

222+
override fun onTimeout(startId: Int) {
223+
super.onTimeout(startId)
224+
stopForegroundService()
225+
}
226+
222227
private fun loadDataFromPreferences() {
223228
foregroundServiceStatus = ForegroundServiceStatus.getData(applicationContext)
224229

0 commit comments

Comments
 (0)