Open yakupbaser opened 3 years ago
First of all I broke my arm so it will take time for me to fix something
Second, in flutter to send data between the android OS and the dart code you need to work with channels which works over an engine. When the app is starts there is a main engine that created with it, but to make the task work when the flutter app is closed I need to create a different engine which isn't communicate with the main engine. In the end it means that you need to treat the task function like another flutter app, you need to initialize everything again in the task function
Which means that what you want me to do isn't possible
I hope that it makes sense and sorry for bad English
i think, you should add startTaskFunctionJustForOnce
i think, you should add startTaskFunctionJustForOnce
You mean creating a task that will be executed only once, and it will execute different code then the periodic task?
pls check https://pub.dev/packages/workmanager
it supports: One off task : runs only once Periodic tasks : runs indefinitely on a regular basis
but the plugins purpose is different
In the WorkManager
you can register multiple tasks (periodic and one off tasks) which will be executed at different times and this is the purpose of the WorkManager
and the plugin is just an api to the built in WorkManager
in android it's like TaskScheduler
in windows.
My plugin purpose is to create a non stop running foreground service and if I implement an option to execute multiple tasks so it's like creating the built in WorManager
of android but thru a foreground service so I don't see a reason for this.
If you want me to add button action or custom foreground layout etc I can add those because I do see this as something that my plugin should do
btw
I actually created this foreground service plugin to use it in my app because of the WorkManager
. In android if your app is closed and you registered tasks in the WorkManager
then after a period if time your tasks will be killed by the battery's phone optimization so I use this foreground service to keep an instance of my app running so my WorkManager
tasks will not be killed
But it has to be a task function runs only once option. For example i have a function. its calculating finish time is 2 minutes and it has backend operations. i want to run it only ones with foreground servise. How can i make this?
But it has to be a task function runs only once option. For example i have a function. its calculating finish time is 2 minutes and it has backend operations. i want to run it only ones with foreground servise. How can i make this?
I see. I will implement something
You can now create a periodic task and kill it after it executed
I'm in a dilemma
I don't know if to create the tasks like so: you can create only one task periodic or one task off or you can create periodic and one off task
what do you say?
how can i send a state to foreground service and get same state from it? May be you can update your plugin about it.
Please check it: https://github.com/fluttercommunity/get_it/issues/145
and i made an example for this problem: https://github.com/yakupbaser/demogetit