Closed teusink closed 11 years ago
Hi, are you going to implement this feature?
Sorry ... yes, but it might be a while yet (as per the same reasons I gave in the other issue).
Once I've got the automated build & test up and running, the plan of attack is:
I just need to work this in with day job, vacation, etc, etc. I'd like to try and get done in July .... but to be honest I suspect it will be August.
Have a question about this. I've got a service that I want to launch once, with startService and I don't want the timer because I've got one Listener in the service. How could I launch the service with no timer? Is it possible or it's needed in order to doWork() ? The issue I have is without enableTimer the service doesn't reach doWork. Thank you very much.
The doWork() is currently called based on the timer. However there is no reason that code cannot be called on some other event (such as a listener).
If you look at the source code for the Background Service (https://github.com/Red-Folder/Cordova-Plugin-BackgroundService-Source/blob/master/src/com/red_folder/phonegap/plugin/backgroundservice/BackgroundService.java), you should be able to extend to run the doWork via another method.
Changes made and committed to Github (https://github.com/Red-Folder/Cordova-Plugin-BackgroundService/commit/1bdea8b9bdd4d0710b399fd588afabbce1229fd6#commitcomment-3956440)
TimerMilliseconds is now part of the returned JSONObject
Awesome, just awesome!
@acuatoria Perhaps you can make doWork just sent a message to the log. And then in: `protected void onTimerEnabled() { // TODO Auto-generated method stub }
Add the listener and its code.
Then from your app start the service and enable the timer and set it to daily. To service would run once a day and send a logcat message. But the listener could be active because of timerenabled.
I did not test it, but perhaps it works. But I do not have experience (yet, I need a shake listener) with this construction.
@acuatoria Never mind. Tested it and it seems to be rather unstable... :)
@acuatoria Firstly, would you be so kind as to raise a separate issue for this request (this may end up being an enhancement).
You are correct that there isn't currently a good way to call the doWork without a timer (it can be done ... but is messy).
Under what circumstances would you want to trigger the doWork without a Timer?
I think I may need to amend the base code to allow doWork to be called by both a timer and on demand.
@Red-Folder @acuatoria I opened one: https://github.com/Red-Folder/Cordova-Plugin-BackgroundService/issues/14
First of all, thanks for this awesome plugin.
As requested I raise this "issue" to tackle the following request.
It would be nice to get the current interval timer of the service. Perhaps a bit same construction like the configuration.
Hope to see this feature in a future release.
Thanks again.