I’m looking for either a permissively licensed Android plugin similar to flutter_background_service, but one that only starts an application’s foreground service on reboot, app upgrade, etc; or a simple way to do this with something like a MethodChannel
in Kotlin or Java.
The reason I would prefer not to use flutter_background_service
at this time is because it requires communication via serializable data structures between isolates, and it does much more than I need, like starting foreground notifications, a behavior my code already handles via flutter_local_notifications. I was looking at building a custom solution based on code from that plugin, but I don’t know much about Android development, and the code is quite complex.
/a/70980729/582326 works, but it displays the app’s main screen on boot. I’d rather not make my app that invasive, so I’m hoping to only launch a foreground service via a sticky notification.
flutter_boot_receiver seems like it would be the right fit, except for its copyleft license. I would prefer not to use that, because I’m working an open source app under the MIT license.
I’ve found help on Stack Exchange including the following: /a/78336034/582326. However I already have an isolate in Dart that starts a foreground service, and I don’t know how to complete step 4 of that answer without using flutter_background_service
.
From what I understand, I may have to open a MethodChannel
to call Flutter code from Java / Kotlin. The Flutter platform-channels documentation explains how to do something similar, but only in the other (and more commonly used) direction. That, and what to call in Java / Kotlin, is where I’m currently stuck.
Pointers to documentation, method calls, or code for calling a Flutter isolate on boot / after an app upgrade would be much appreciated.