Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Current interval timer request. #5

Closed
teusink opened this issue May 21, 2013 · 10 comments
Closed

Current interval timer request. #5

teusink opened this issue May 21, 2013 · 10 comments

Comments

@teusink
Copy link

teusink commented May 21, 2013

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.

@teusink
Copy link
Author

teusink commented Jul 4, 2013

Hi, are you going to implement this feature?

@Red-Folder
Copy link
Owner

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:

  • Build/ Compile for Cordova version beyond 2.7
  • Add this function
  • Recheck the code for uncaught exceptions (I think I have a small hole somewhere given on of the other issues

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.

@acuatoria
Copy link

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.

@Red-Folder
Copy link
Owner

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.

@Red-Folder
Copy link
Owner

Changes made and committed to Github (1bdea8b#commitcomment-3956440)

TimerMilliseconds is now part of the returned JSONObject

@teusink
Copy link
Author

teusink commented Aug 27, 2013

Awesome, just awesome!

@teusink
Copy link
Author

teusink commented Sep 2, 2013

@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.

@teusink
Copy link
Author

teusink commented Sep 2, 2013

@acuatoria Never mind. Tested it and it seems to be rather unstable... :)

@Red-Folder
Copy link
Owner

@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.

@teusink
Copy link
Author

teusink commented Sep 2, 2013

@Red-Folder @acuatoria I opened one: #14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants