The application prints the latitude and longitude of the smartphone onto the screen demonstrating how to use the LBS API with GPS. The example is the same for mobile phones with either internal or external GPS as the API automatically searches for an internal GPS receiver once started and if none is found it then searches for an external receiver by initiating a Bluetooth discovery session.
A client application has to set up a connection to the LBS server
by calling RPosition-Server::Connect()
to enable it
to retrieve positional information. Then the client must initiate
a subsession to the connected server instance by using one of the OpenL()
method overloads of the RPositioner
class. Once the connection is established, a requestor for the location
service is identified in order to use it.
LBS require the implementation of an active object to manipulate
the asynchronous calls for location information acquisition. For this
purpose, we have implemented the active object class CFindMeActive
, which is derived from CActive
, implementing its
two pure virtual functions RunL()
and DoCancel()
.
The class encapsulates all necessary information and constructions
for operating the location service.The second-phase ConstructL()
method performs the main actions to connect to the server as previously
discussed. When ConstructL()
is executed, the active
object submits an asynchronous request to receive positional information
from the server. When positional data is available, RunL()
is called by the active scheduler (which schedules all current active
objects) to handle this obtained data.
The function checks whether the position was updated successfully, before requesting the view to update the screen with this newly available positional data. It also issues a new request to get updated positional data. The application continues retrieving location data in this manner until it shuts down.
Click on the following link to download the example: FindMe.zip
Click: browse to view the example code.
RPositionerServer RPositioner TPositionInfoBase
TPositionUpdateOptions