You Are Here:

Community: Wiki

This page was last modified on 5 June 2009, at 12:18.

Location API

From Forum Nokia Wiki

Location API (JSR-179) allows Java ME applications to get the user geographic location.

The implementation of this technique in the device can be:

  • A GPS technology, like the one in Nokia N95.
  • Using the mobile phone network (with Cell ID).
  • Using short-range positioning systems.

The most common solution is the GPS one, as the others need operators APIs or some hardware installed on buildings.

This API adds javax.microedition.location package, that enables developers to write wireless location-based applications and services and can be implemented with any common location method. The APIs provide mobile applications with information about the device's present physical location and orientation (compass direction), and support the creation and use of databases of known landmarks, stored in the device.

Classes

There is a Location class that abstract the location of the user. It has, inside, a Coordinates (latitude and longitude) and, sometimes, speed and optional information about the place.

You can also define Landmark objects with a name and description. They are stored in the LandmarkStore in the device for future use. If the device supports a compass, you can have an Orientation class.

Criteria class is key to influencing how the device will acquire location

// The following sample code describes how to use Location API

double lat,lon;
QualifiedCoordinates qc=null;
Criteria cr=new Criteria();
cr.setHorizontalAccuracy(500);
cr.setVerticalAccuracy(500);
cr.setPreferredPowerConsumption(Criteria.POWER_USAGE_LOW);
LocationProvider lp=LocationProvider.getInstance(cr);
Location loc=lp.getLocation(60);
qc=loc.getQualifiedCoordinates();
AddressInfo adinfo = loc.getAddressInfo();
String place="";
if(adinfo!=null){
place = adinfo.getField(AddressInfo.COUNTRY);
}
 
// To get the latitude and longitude
lat = qc.getLatitude();
lon = qc.getLongitude();

Receiving updates from a LocationProvider: javax.microedition.location.LocationListener In the LocationListener interface setLocationListener method is used to receive the updates setLocationListener(listener,interval,timeout,maxAge); • Interval — how often you want fix updates, in seconds • Timeout— how late update can be from interval, in seconds • maxAge— acceptable age for cached info to be returned

Related Wiki Articles

No related wiki articles found

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2findeE78E2ephpE2fFileE3aGpsPositionE52eE71uestE2ezipX qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqfntypeZWikiContentQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZgpsQ qfnZtopicQUqfnTopicZlocationQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZtypeQUqfntypeZWikiContentQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqfntypeZWikiContentQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ