flutter_foreground_task
flutter_foreground_task copied to clipboard
When running in own Android process get "did not then call Service.startForeground()" by second start
Hello, when I declare in Manifest android:process=":myProcessName"
for the com.pravera.flutter_foreground_task.service.ForegroundService
like this:
<service
android:name="com.pravera.flutter_foreground_task.service.ForegroundService"
android:process=":myProcessName" />
It works fine only for the first time. By second start I get the error that Service.startForeground()
was not called.
E/AndroidRuntime(27873): android.app.ForegroundServiceDidNotStartInTimeException: Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{685716d u0 city.russ.alltrackervideosecurity/com.pravera.flutter_foreground_task.service.ForegroundService}
E/AndroidRuntime(27873): at android.app.ActivityThread.throwRemoteServiceException(ActivityThread.java:1927)
E/AndroidRuntime(27873): at android.app.ActivityThread.access$2700(ActivityThread.java:247)
I finish my ForegroundService as usual:
await FlutterForegroundTask.stopService();
Anyone any idea why this happens?
My flutter:
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.0.0, on Microsoft Windows [Version 10.0.19043.1706], locale de-DE)
[√] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.11.5)
[√] Android Studio (version 2021.1)
[√] IntelliJ IDEA Ultimate Edition (version 2021.2)
[√] VS Code (version 1.62.3)
[√] Connected device (5 available)
plugin:
flutter_foreground_task: ^3.7.3
I'm having the same problem; however no clear repro steps (the crash is reported by users). @RUSSCITY have you found a solution or workaround for this?
@akospwc the same problem here, very hard to reproduce it... But I have tried many possible things, and (at least I think so, maybe placebo) it doesn't crash now. You can try or check my changes. I'm not sure if it clean code, because I was fixing it, without deep driving in the library. Therefore I didn't create any PR.
flutter_foreground_task:
git:
url: https://github.com/RUSSCITY/flutter_foreground_task.git
ref: 82f45d7
I would be happy if the owner could find and fix the root problem of this.
Just
<service android:name="com.pravera.flutter_foreground_task.service.ForegroundService" />
works fine for me