File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
android/src/main/kotlin/com/pravera/flutter_foreground_task/service Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -60,7 +60,10 @@ class ForegroundServiceManager {
6060 ForegroundTaskOptions .updateData(context, argsMap)
6161 ForegroundTaskData .updateData(context, argsMap)
6262 NotificationContent .updateData(context, argsMap)
63- ContextCompat .startForegroundService(context, nIntent)
63+ // Use startService instead of startForegroundService because the service
64+ // is already running in the foreground and we only need to deliver the
65+ // update command. This avoids the startForeground() contract requirement.
66+ context.startService(nIntent)
6467 }
6568
6669 /* * Stop the foreground service. */
@@ -76,7 +79,10 @@ class ForegroundServiceManager {
7679 ForegroundTaskOptions .clearData(context)
7780 ForegroundTaskData .clearData(context)
7881 NotificationContent .clearData(context)
79- ContextCompat .startForegroundService(context, nIntent)
82+ // Use startService instead of startForegroundService because the service
83+ // is already running in the foreground and we only need to deliver the
84+ // stop command. This avoids the startForeground() contract requirement.
85+ context.startService(nIntent)
8086 }
8187
8288 /* * Send data to TaskHandler. */
You can’t perform that action at this time.
0 commit comments