You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wanted to register a periodic task that could start foreground service (FGS) after a set delay, but it failed to run. The execution of the foreground service is done by yet another flutter package called flutter_foreground_task https://pub.dev/packages/flutter_foreground_task.
Details
The start of the FGS is triggered using FlutterForegroundTask.startService from the flutter_foreground_task package, and it is called from inside of the callback body of Workmanager().executeTask((task, inputData) async { ... }), which is called from the top-level callbackDispatcher() entry point. Therefore by design, when Workmanager().registerPeriodicTask( ... ); is called the FGS should begin autonomously, but it did not. My guess is that Android disallows FGS to launch from another isolate without proper passing of Android context. But since I am using a third-party FGS package there's really no wiggle room here.
I am beginning to lean towards to the concept of Android's ForegroundInfo though. And someone #573 has already raised a merge request regarding this feature, ready to be released. I am paying close attention to the progress of this.
Output of flutter doctor -v (partial)
[√] Flutter (Channel stable, 3.22.1, on Microsoft Windows [Version 10.0.22631.4602], locale en-US)
• Flutter version 3.22.1 on channel stable at C:\dev\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision a14f74ff3a (7 months ago), 2024-05-22 11:08:21 -0500
• Engine revision 55eae6864b
• Dart version 3.4.1
• DevTools version 2.34.3
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at C:\Users\Chuyue Wu\AppData\Local\Android\sdk
• Platform android-34, build-tools 34.0.0
• Java binary at: C:\Program Files\Android\Android Studio1\jbr\bin\java
• Java version OpenJDK Runtime Environment (build 17.0.9+0--11185874)
• All Android licenses accepted.
Synopsis
I wanted to register a periodic task that could start foreground service (FGS) after a set delay, but it failed to run. The execution of the foreground service is done by yet another flutter package called flutter_foreground_task https://pub.dev/packages/flutter_foreground_task.
Details
The start of the FGS is triggered using
FlutterForegroundTask.startService
from the flutter_foreground_task package, and it is called from inside of the callback body ofWorkmanager().executeTask((task, inputData) async { ... })
, which is called from the top-levelcallbackDispatcher()
entry point. Therefore by design, whenWorkmanager().registerPeriodicTask( ... );
is called the FGS should begin autonomously, but it did not. My guess is that Android disallows FGS to launch from another isolate without proper passing of Android context. But since I am using a third-party FGS package there's really no wiggle room here.I am beginning to lean towards to the concept of Android's ForegroundInfo though. And someone #573 has already raised a merge request regarding this feature, ready to be released. I am paying close attention to the progress of this.
Output of
flutter doctor -v
(partial)[√] Flutter (Channel stable, 3.22.1, on Microsoft Windows [Version 10.0.22631.4602], locale en-US)
• Flutter version 3.22.1 on channel stable at C:\dev\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision a14f74ff3a (7 months ago), 2024-05-22 11:08:21 -0500
• Engine revision 55eae6864b
• Dart version 3.4.1
• DevTools version 2.34.3
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at C:\Users\Chuyue Wu\AppData\Local\Android\sdk
• Platform android-34, build-tools 34.0.0
• Java binary at: C:\Program Files\Android\Android Studio1\jbr\bin\java
• Java version OpenJDK Runtime Environment (build 17.0.9+0--11185874)
• All Android licenses accepted.
[√] Android Studio (version 2023.2)
• Android Studio at C:\Program Files\Android\Android Studio1
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.9+0--11185874)
[√] VS Code (version 1.94.2)
• VS Code at C:\Users\Chuyue Wu\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.102.0
The text was updated successfully, but these errors were encountered: