February 27, 2021
Hot Topics:

Using Location-Enabled MIDlets for Mobile Navigation

  • By Jayasurya Venugopalan
  • Send Email »
  • More Articles »

Location information has become fairly easy to access nowadays, even on mobile devices. The widespread availability of GPS chipsets such as the SiRF chipsets, which are accurate to within a few meters, as well as the significantly lower costs of these products, have contributed to the accessibility. The Location API for J2ME (JSR 179) even makes it very easy for developers to integrate location information into mobile applications.

This article illustrates how to combine JSR 179 and Scalable Vector Graphics (SVG) to provide navigation for a GPS-enabled mobile device. The application will employ the Scalable 2D Vector Graphics API for J2ME (JSR 226) and a MIDlet. As an example, the article provides and refers to a sample NetBeans project for a college "campus navigation" application.

Author's Note: The content of the article is the view of the author and not that of Wipro Technologies.

Determining the Device Location

You can determine the location of a mobile device in several ways. Mobile-location methods can be based either on a network or a mobile device. In the network-based location method, you have the following options:

  • The Cell-ID method. This method identifies the location of the handset from the Base Transceiver Station (BTS) that the handset is communicating with and the location of that BTS. Its precision is determined by the size of the cell, and it can be quite inaccurate.
  • Enhanced-Observed Time Difference (E-OTD)/Uplink Time Difference of Arrival (U-TDOA)/Observed Time Difference of Arrival (OTDOA) methods. These methods use monitored time differences to locate the mobile device. Their precision depends on the precision of the mobile network's system time.

In mobile-based location methods, you have GPS (Global Positioning System). GPS is potentially the most accurate method, but it has a couple of drawbacks. First, it consumes a lot of battery power while in use. Second, its performance suffers in canyon environments such as cities, where satellite visibility is intermittent, tall buildings block the GPS signals, and satellite signals are too limited to estimate the position of the user.

The following are the two types of mobile-based location methods for GPS:

  • Assisted Global Positioning Systems (A-GPS). For a mobile device equipped with an A-GPS receiver, the network uses the cell that the mobile device communicates with to locate the GPS satellite. It then sends this location information to the mobile device, which uses it to narrow the satellite searching scope and shorten the searching time.
  • Autonomous GPS. For a mobile device with a full-function GPS receiver, the mobile device obtains the location information itself. It may, however, take some time to get an initial fix on the visible satellites.

Most modern mobile devices that have a mobile GPS chipset and use KVM will support JSR 179. Table 1 lists the main JSR 179 Location API classes.

LocationProviderUsed for the selection of the location provider
CriteriaRepresents a source of the location information, starting point of location request
LocationRepresents the standard set of basic location information. This includes the time-stamped coordinates, accuracy, speed, course, etc.
CoordinatesRepresents coordinates as latitude-longitude-altitude values.
LocationListenerListener that receives update events associated with a particular LocationProvider
ProximityListenerReceives updates based on terminal crossing into a defined radius around a coordinate.
LandmarkThe Landmark class represents a landmark, such as a known location with a name (such as a monument)
LandmarkStoreThe LandmarkStore class provides methods to store, delete and retrieve landmarks from a persistent landmark store.
Table 1. Main JSR 179 Location API Classes

The NetBeans Project

The NetBeans project LocationEnabMidletProj.zip is provided here for demonstration. After unzipping the project, you can open it in NetBeans (The examples discussed here are from NetBeans IDE 6.5.1). You can test it on the Java Wireless Tool Kit, which comes as part of the NetBeans Mobility Pack.

If you use a Nokia mobile phone, the Nokia PC Suite allows you to deploy the sample MIDlet from the NetBeans environment directly on the phone through a USB cable. Use a similar methodology for mobile phones from other vendors.

The following are screenshots of the running application on an emulator.

Click here for larger image

Figure 1. Map Screen: This capture of the emulator shows the running MIDlet displaying the campus of Brock University.

Click here for larger image

Figure 2. Map Screen Menu: This capture shows the screen menu for the campus navigation with zoom in and zoom out facility.

Click here for larger image

Figure 3. Zoomed Map Screen: This capture shows the zoomed campus.

The Sample SVG File

A sample SVG file, which is used by the MIDlet, invokes the Campus JPEG file from a web server. For testing with the Java Wireless Tool Kit emulator, the web server can be hosted on the development machine that runs NetBeans.

The SVG file first defines the DTD and the SVG Tiny version used by the mobile device (SVG Tiny 1.2 in this case). The SVG size and the image size are then defined, and the image definition is linked to the URL of the image on the web server. Finally, lines are defined vertically and horizontally to form a grid for ease of location (see Listing 4, which defines the image and its location, as well as the grid for the mobile display of the campus).

Page 1 of 4

This article was originally published on June 18, 2009

Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Thanks for your registration, follow us on our social networks to keep up-to-date