Implementation of the Tourist Route MIDlet

Application Architecture

In the TouristRoute example MIDlet, all the UI classes are included in the com.nokia.example.location.tourist.ui package. Model classes can be found from the com.nokia.example.location.tourist.model package. In this example, only the classes in the model package use Location API functionality. When using the TouristRoute MIDlet to get acquainted with the Location API, the model layer classes might be the most interesting ones to take a look at. The UI layer classes only contain the MIDlet-specific UI implementation and might not help much in learning how to use the Location API. In addition, command controller logic is coded in the UI classes. The figure below shows TouristRoute example's classes and relationships.

Figure 167: TouristRoute MIDlet's class diagram

The model layer classes and interfaces include the following tasks:

Startup Sequence

TouristRoute example MIDlet startup performs an automatic location provider search. The MIDlet use can begin after the location provider is found and the MIDlet is capable of receiving a location update event. The purpose of this section is to clarify the TouristRoute example MIDlet's startup sequence.

The use of a network-based location provider may require the user to pay a fee. TouristRoute first tries to find a free location provider from a set of predefined location providers. If no free location providers are available, TouristRoute confirms with the end user whether (s)he wants to use a non-free service. The TouristRoute MIDlet uses predefined cost Criteria in searching for location providers.

The sequence diagram in below figure demonstrates the idea of how the TouristRoute MIDlet searches location providers. At first, the MIDlet looks for free location providers. If none are found, the MIDlet asks the user for permission to continue the search with non-free providers. If a cost-free location provider (for example, a GPS module over a Bluetooth connection) is found, the location provider search will end. When a location provider is found and selected, the example MIDlet receives providerSelectedEvent().

At this point, the MIDlet registers to listen for events from the selected location provider. Especially when using a GPS module as a location provider, the first position calculation may take a while. That is why the first locationUpdated() event arrival on the TouristData class may take a while. When the first locationUpdated() event arrives, the firstLocationUpdateEvent() event is sent to the TouristMIDlet class. At this stage the application UI (TouristUI) is set to visible.

Note: Some location modules may take longer to start than others and the states of the module might change between module manufacturers. This means that you should take into account that the first location fix can take some time to retrieve due to the module startup time and satellite signal strengths.

Figure 168: Sequence diagram of MIDlet startup and location provider search