How to synchronize a network update on N9 in QML
This article explains how to trigger a job, usually a network update, that is synchronized with other network activity.
Article Metadata
Tested with
Compatibility
Platform Security
Article
Introduction
This short article gives an example of the AlignedTimer QML object from the Qt Mobility 1.2 API. This component allows the creation of a timer that will be triggered at the same time as other applications' timers. This is useful to synchronize updates, for example to group network updates together (reduce power consumption on mobile devices).
Summary
The following code shows an example of AlignedTimer. This timer will be triggered between 15 and 30 minutes later, based on other applications' use of AlignedTimers. The system will try to synchronize them as much as possible, to reduce the number of wake-ups, or number of times the network needs to be brought up.
import QtQuick 1.0
import com.nokia.meego 1.0
import QtMobility.systeminfo 1.2
PageStackWindow {
id: window
[...]
// Create the AlignedTimer
AlignedTimer {
id: alignedTimer
// Set the timer to trigger between 15 and 30 minutes
// Other applications using an AlignedTimer would be triggered
// during this same interval (for example mail sync) if possible
maximumInterval: 30*60 // in seconds
minimumInterval: 15*60 // in seconds
singleShot: true // Run it only once. Comment this line for a recurring timer
onTimeout: {
// Place update code, such as network sync here
}
}
Component.onCompleted: {
// Start the time once the PageStackWindow is created (application loaded)
alignedTimer.start()
}
[...]


Hamishwillee - A few questions
- Would this run on Symbian? Doesn't seem to be any reason to make this specific to N9. How about "How to synchronise network updates across apps in QML"
- Can we have a downloadable example zip?
- It is useful to provide links to the Qt Mobility API reference.
Thanks for this, its a new API I didn't know about and I can see the value. Can you think of any other use cases than network activity for this - perhaps any sort of wakeup/notification that isn't particularly time senstive - for example I'd think most anniversary notifications from calendar could be made anywhere between 10 am and evening.?hamishwillee 02:05, 5 December 2011 (EET)
Ltomuta - @Hamishwillee
The AlignedTimer API, or rather its functionality, is currently missing on Symbian, but will be coming in the next platform release (IIRC). Until then, this remains a platform specific solution.ltomuta 17:36, 6 December 2011 (EET)