Join Now
Quality Rating:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)
Expertise Level:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)

This page was last modified 18:33, 18 December 2007.

How to get Location Using Location API JSR 179

From Forum Nokia Wiki

/*


  • This Midlet is for getting the lat, lon and country info.


@ author Senthil


 *


/


import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.location.*;
import javax.microedition.io.*;
import java.io.*;


public class LocationMidlet extends MIDlet implements CommandListener {

Command Exit = new Command("Exit",Command.EXIT,0);
private StringItem location = new StringItem("\n Location:","");;
public QualifiedCoordinates qc;
public LocationMidlet() { }

public void startApp() {
Form f=new Form("Location Demo");
f.append("Finding for location...\n");

f.addCommand(Exit);
f.setCommandListener(this);
Display.getDisplay(this).setCurrent(f);
try {
Criteria c=new Criteria();
c.setHorizontalAccuracy(500);
c.setVerticalAccuracy(500);
c.setPreferredPowerConsumption(Criteria.POWER_USAGE_LOW);
LocationProvider lp=LocationProvider.getInstance(c);
Location loc=lp.getLocation(60);
qc=loc.getQualifiedCoordinates();
AddressInfo adinfo = loc.getAddressInfo();
String place="";
if(adinfo!=null)
place = adinfo.getField(AddressInfo.COUNTRY);

f.append("Address: "+place+"\n");
f.append("Alt: "+qc.getAltitude()+"\n");
f.append("Lat: "+qc.getLatitude()+"\n");
f.append("Long: "+qc.getLongitude()+"\n");


} catch(Exception e) {
f.append("Exception: "+e);
}
}

public void pauseApp() {}

public void destroyApp(boolean destroy) {}

public void commandAction(Command c, Displayable s) {
if (c == Exit) {
destroyApp(true);
notifyDestroyed();
}
}


}

Related Discussions
Thread Thread Starter Forum Replies Last Post
Location API shuaiying Mobile Java General 0 2004-04-12 04:17
GPS on N95 and java edudesouza Mobile Java Tools & SDKs 16 2007-07-18 09:13
did Nokia series was supports the Location API lakshmanraob Mobile Java General 5 2005-11-16 04:37
JSR Support and MIDlets Paranoid_Android Mobile Java Networking & Messaging & Security 12 2006-10-20 14:02
Problem with accessing the build-in GPS on nokia (N95) crJava Mobile Java General 14 2008-04-07 11:30
 
Powered by MediaWiki
     
     RDF Facets:
     
     
     qfnZtypeQUqfnTypeZCommunityContentQ
     qfnZtypeQUqfnTypeZWebpageQ
     qfnZtypeQUqfnTypeZWikiContentQ
     qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX