11-24-2011 02:23 PM
do you have any recommendation for a recurring task that needs to be done in the background? I am asking because I need to drop some entries in a database from time to time in a webworks project.
What I am thinking about was, first at the start for sure or (if this app is capable of) when a push message arrives.
How would you solve this in a clean way?
11-24-2011 02:32 PM
1. You can keep your app running in the background by catching the exit event using the blackberry.app.event.onExit() and requesting blackberry.app.requestBackground()
3. You can (and must) capture push messages via the OpenB*SPushListener onPush() callback method. You can do whatever you want in there. See here for an example.
11-24-2011 02:47 PM - edited 11-24-2011 02:51 PM
I'm not sure about that, I couldn't find any documentation on it. However, I assume any other manual implementation would drain the battery as much or more than the native setInterval(). Currently there is no native WebWorks API that duplicates this functionality.
I use setInterval in my app without much issue. I'm running openBISPushListener() once an hour. Somebody else may have further insight into the CPU (read: battery) usage of the setInterval though.
To maximize the performance of setInterval():