Enterprise J2ME Developing Mobile Java Applications [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Enterprise J2ME Developing Mobile Java Applications [Electronic resources] - نسخه متنی

Michael Juntao Yuan

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید



18.4 Enhancing the Driving Directions Application


The driving directions application we demonstrated above is not particularly easy to use. For example, if we are lost while driving around, we need to find the route from the current location to the destination. To find out the current street address and manually enter it into the device could be a major nuisance. A driving directions application that is aware of the current location context and automatically fills out the From field can be much more valuable to users. In fact, most LBS business models require access to the mobile client's current location.


18.4.1 Location Determination Techniques


There are several ways to obtain the current locations of mobile devices.

Terminal-based: A GPS-equipped device can calculate its coordinates using GPS satellite signals. This method is accurate and straightforward, and it works everywhere in the world. However, GPS modules are expensive, slow, and a drain on batteries.

Network-based: Cellular network operators can determine location of any phone in the network using its signal strength received by three nearby access stations (triangling). On-device smart applications (e.g., the driving directions application) can access the location data via the data network. With user authorization, the location data can also be made available to third parties from the carrier's Web site. This is an excellent approach if we need to track a large number of users from the back end (e.g., push services). However, the drawbacks are that the user must be within the cellular network coverage; the service is not yet available nationally, and the location accuracy is not as good as the GPS approach.

Network-assisted GPS: Of course, we can combine the above two approaches: GPS devices can use network data to determine an approximate position first and then use the GPS module to get accurate corrections. This speeds up the GPS look-up process considerably.

Local wireless network-based: Advances in new technologies will also enable location determination in local wireless networks, such as WiFi and Bluetooth networks, in the future.

User-assisted: As the last resort, we can also ask the user to identify the closest landmark and calculate an approximate coordinate based on the known coordinate of the landmark. This works well in controlled environments like a college or company campus.


Note

The Oracle wireless application server works with wireless carrier location servers to provide SOAP interfaces for network-based location data of all devices in the network.


What Is E911?


The Enhanced 911 (E911) is a government initiative to enable the police and emergency workers to determine the location of any cell phone caller in the United States. It requires all U.S. wireless carriers to install network-based location tracking systems and make the data available to authorized government agencies. Once deployed, E911 will create a universal cell phone location system available to commercial location-based service providers.

The original timetable for E911 was to have the complete deployment by the end of 2004, but it has been delayed significantly in the past several years. The completion time is now estimated to be 2007.


18.4.2 The Location API for J2ME


The J2ME Location API (JSR 179) is a standard Optional Package for both CDC-based and CLDC-based devices. It allows J2ME applications to access location information on any device through standard APIs regardless of the underlying technology and service provider. Table 18.2 shows the entire J2ME Location API defined in the javax.microedition.location package. It is based on the v1.0 final release (September 2003).

Table 18.2. The javax.microedition.location Package

Class

Description

AddressInfo

Contains information about an address, such as building number, street number, city, and state.

Coordinates

Represent three-dimensional geographic coordinate information (i.e., longitude, latitude, and altitude) from GPS devices or network operators.

QualifiedCoordinates

Extend the Coordinates with 1-sigma error bars qualifying the accuracy of the coordinates data.

Orientation

Contains data about the device's three-dimensional orientation. It is up to the device to define its own axes.

Location

Holds information about the device's current location, including the current QualifiedCoordinates, speed, course, coordinates retrieval method, and an optional AddressInfo.

LocationProvider

It is the factory class to retrieve Location from underlying providers (e.g., GPS device interface or network location server).

Criteria

Specifies criteria to select location providers. Those criteria include cost, accuracy, response time, power consumption, and supported features.

LocationListener

It is a listener interface that can be registered with a LocationProvider. It handles events of location and provider state changes.

Landmark

Represents a location with a known address.

LandmarkStore

Represents a collection of Landmark objects.

ProximityListener

This is a listener interface that can be registered with a LocationProvider. It handles events when the device enters the proximity radius of the specified coordinates.

Note

CLDC v1.1 is required for the J2ME Location API because coordinates are expressed in float or double numbers.

Listing 18.3 illustrates how to construct a simple location-based application using the JSR 179 API. For more information about the J2ME Location API and usage examples, please refer to JSR 179 documentation.

Listing 18.3. A simple J2ME Location API application



Criteria criteria = new Criteria ();
criteria.setPreferredResponseTime(20);
criteria.seVerticalAccuracy(10);
// set other criteria
LocationProvider provider =
LocationProvider.getInstance(criteria);
// The StepTracker's locationUpdated() method
// will be called every 1 second until the 100th second.
// The passed location data cannot be more than 2 seconds old.
StepTracker tracker = new StepTracker ();
provider.setLocationListener(tracker, 1, 100, 2);
// Add the collision handling logic. The CollisionHandler's
// proximityEvent() method is called when the device
// enters the 0.5 meter radius of either coord1 or coord2
Coordinates coord1 = new Coordinates(lat1, long1, alt1);
Coordinates coord2 = new Coordinates(lat2, long2, alt2);
CollisionHandler collision = new CollisionHandler ();
provider.addProximityListener(collision, coord1, 0.5);
provider.addProximityListener(collision, coord2, 0.5);
public StepTracker implements LocationListener {
public StepTracker () {
}
// Both threads below must return immediately.
// So, put long processes in a separate thread.
public void locationUpdated (LocationProvider provider,
Location location) {
// Do something with the new location
// For example, update the steps on a map.
}
public void providerStateChanged(LocationProvider provider,
int newState) {
// Handle the state change. For example, if the
// provider becomes unavailable, alert the user.
}
}
public CollisionHandler implements ProximityListener {
public CollisionHandler () {
}
public void proximityEvent(Coordinates coordinates,
Location location) {
// Handle the collision here.
// For example, alert the user and provide a direction
// to move away from the collision point.
}
public void monitoringStateChanged(boolean isActive) {
// Handle the state change in the provider
}
}


/ 204