-
Notifications
You must be signed in to change notification settings - Fork 85
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
Feature request: execute doWork not only based on a time, but also on demand. #14
Comments
Is the intention to run code in the background (java) or in the foreground (javascript)? |
Intention is to create a listener that runs Java code. Roughly the same as it is now, only without the timer. |
Code written. Just need to test and upload. Hopefully get a chance this weekend. |
Wow, awesome! www.teusink.org
|
Added runOnce() support this morning. This can be run from Javascript (via the Plugin) or from the Background Service. The runOnce() will run the doWork() then update the latest result (in the same manner as the timer does). This means that reading the LatestResult within your Javascript will return the result of the runOnce execution (assuming it was the last to run). Neither the Plugin or Background Service runOnce() accept any parameters - so if you need data to work on in your doWork() then you will need to pass this out-of-band. For the Plugin (from Javascript) I'd recommend sending the data in setConfig. For the Background Service I'd recommend setting a member field/ variable. I'll leave this issue open until such time as I've had a chance to document an example of its use. |
@Red-Folder Nice! I hope I have sunday time to test it. I will add a listener for a shake and upon shake code will be executed. I will let you know what the outcome is. Thanks! |
I am testing with it, and pretty much everything seems to work. I notice that after the service is started, the runOnce is not automatically run. When it comes to biding listeners in the service this is not handy. Because sometimes Android restart services and the listener is gone. I have to manually do a runOnce in order to get things back to working. Any thoughts on this? |
Override protected abstract JSONObject initialiseLatestResult(); Put the listener setup in there. This should be called if Android restarts the service. Let me know how you get on |
That should probably do the trick indeed. I will test that out. Another question. Since I run the latest version somehow the getStatus doesn't result in a succes callback (or something). I had nested some things like this:
The callback of the getStatus command is the handleAutoChangerSucces part. When the service is not running it should automatically start it. Edit: |
Never mind. It is the "handleAndroidPreferences" part. The callback takes to long or something to properly do the comparison. |
Please help me, I have a error: Error: Plugin unable to bind to background servace |
@vladjiss Please stop adding comments to existing issues. The issue should be kept on topic. Please create a new issue and provide a copy of your code so that I can assist. It will almost certainly be because you have missed a step in the instructions - which I'm prepared to help with, but please stop spamming the issues list |
I have now documented the runOnce functions, these can be found in the new repo WIKI:
Now documented I consider this issue closed |
This to make it possible to bind an listener to the app.
Example:
Stackoverflow example code: http://stackoverflow.com/questions/2317428/android-i-want-to-shake-it
The text was updated successfully, but these errors were encountered: