Skip to content

Commit 67da414

Browse files
bytebubblesDev-hwang
authored andcommitted
fix-Android: foregroundServiceStatus UninitializedPropertyAccessException
1 parent d6e4d3f commit 67da414

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,10 @@ class ForegroundService : Service() {
199199
stopForegroundService()
200200
unregisterBroadcastReceiver()
201201

202-
val isCorrectlyStopped = foregroundServiceStatus.isCorrectlyStopped()
202+
var isCorrectlyStopped = false
203+
if (::foregroundServiceStatus.isInitialized) {
204+
isCorrectlyStopped = foregroundServiceStatus.isCorrectlyStopped()
205+
}
203206
val isSetStopWithTaskFlag = ForegroundServiceUtils.isSetStopWithTaskFlag(this)
204207
if (!isCorrectlyStopped && !isSetStopWithTaskFlag) {
205208
Log.e(TAG, "The service was terminated due to an unexpected problem. The service will restart after 5 seconds.")

0 commit comments

Comments
 (0)