Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
New Contributor
Posts: 8
Registered: ‎02-10-2013
My Device: BB10 Dev Alpha B

Timed Events

Is there a way to setup a timed event that a BB10 Cascades app can respond to? For example, if I want my app to start checking Geolocation information at some specified time.

 

Any suggestions are appreciated!

Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Timed Events

Do you want this to occur only if the app is currently running, or are you asking about having the app launched at that time even if it's not running?

The former is a very simple thing to do with a QTimer.

The latter is currently not possible without the use of an external server and the Push service.

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
New Contributor
Posts: 8
Registered: ‎02-10-2013
My Device: BB10 Dev Alpha B

Re: Timed Events

Thanks for your quick reply. I just looked at QTimer and it seems like it only goes off after some interval. What I'm looking for is more like something tha would go off at a specific datetime, which could be recurring. Is there a way to achieve this with QTimer, or would you recommend something else?

Thanks agian!

New Contributor
Posts: 8
Registered: ‎02-10-2013
My Device: BB10 Dev Alpha B

Re: Timed Events

Oh, and in response to your question, although it'd be nice for it to occur while the app isn't running, I'm not sure if that's going to be possible right now, but I'd definitely like this to occur while the app is running.

Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Timed Events

QTimer has a property "singleShot" which can be set true to avoid the periodic behaviour, though that doesn't seem to be what you meant by interval.

If you just want it to go off at a specific time in the future, you use QDateTime (or in QML just the regular JavaScript Date object) to calculate the difference between now and the future time, and set that as the interval.

There are other approaches possible, but this is easiest for most cases.

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
New Contributor
Posts: 8
Registered: ‎02-10-2013
My Device: BB10 Dev Alpha B

Re: Timed Events

Ok thanks, I think I understand how this could work with a QTimer. I was hoping there'd be some "cleaner" way do it maybe, that would make it easier to have it occur weekly, or on certain days of a week, although I can imagine that could all be done by calculating all the right timer intervals.

You said there are other appropaches possible? Are they much harder? Could it be done by responding to a calendar event, for example? That sounds like it'd be easier if it's possible.