In this part of the porting series we’re going to cover Location APIs to acquire the geo position of a device.
Integrating geo positioning in your app is a breeze. Speaking at a high level, BlackBerry 10 supports the following positioning sources.
With only 3 lines of code, you can start a location session for periodic updates.
// Create the position source QGeoPositionInfoSource *source = QGeoPositionInfoSource::createDefaultSource(this); // connect the signal to listen for position updates connect(_positionSource, SIGNAL(positionUpdated(const QGeoPositionInfo &)), this, SLOT(positionUpdated(const QGeoPositionInfo &)) ) // Start updates source->startUpdates();
While this is quick and easy, you can also control other parameters such as the position source or the interval at which location fixes are sent to your slot.
To query for a single location fix, simply change the last line to:
// Request a single update source->requestUpdate();
A comprehensive and open source sample application is available at:
You can also read the developer documentation for Location here: