java left logo
java middle logo
java right logo
 

Home arrow Java ME Tips arrow MIDP arrow Location Based Services on J2ME devices
 
 
Main Menu
Home
Java Tutorials
Book Reviews
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Java Network
Java Forums
Java Blog




Most Visited Tips
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Book Reviews
Top Rated Tips
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Book Reviews


Statistics
Registered Users: 4093
Java SE Tips: 614
Java ME Tips: 202
Java EE Tips: 183
Other API Tips: 779
Java Applications: 298
Java Libraries: 209
Java Games: 16
Book Reviews:
 
 
 
Location Based Services on J2ME devices E-mail
User Rating: / 43
PoorBest 

J2ME (JSR 179) is a set of generic APIs that can be used for developing location-based services.J2ME location APIs provide mobile applications with information about the device's present physical location and orientation in lattitude-longitude-altitude, and support the creation and use of databases of known landmarks, stored in the device.

Illustration display physical location of mobile device.

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

public class locationMidlet extends Midlet implements CommandListener {
    
    Command Exit = new Command("Exit",Command.EXIT,0);
    public locationMidlet() {}
    
    public void startApp() {
        Form f=new Form("Waiting...");
        f.append("Finding for location...");
        f.addCommand(Exit);
        f.setCommandListener(this);
        Display.getDisplay(this).setCurrent(f);
        try {
            Criteria c=new Criteria();
            c.setHorizontalAccuracy(1000);
            c.setVerticalAccuracy(1000);
            c.setPreferredPowerConsumption(Criteria.POWER_USAGE_LOW);
            LocationProvider lp=LocationProvider.getInstance(c);
            Location loc=lp.getLocation(60);
            QualifiedCoordinates qc=loc.getQualifiedCoordinates();
            f.append("Alt: "+qc.getAltitude());
            f.append("Lat: "+qc.getLatitude());
            f.append("Long: "+qc.getLongitude());
            
        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 Tips

 
< Prev   Next >

Page 1 of 0 ( 0 comments )

You can share your information about this topic using the form below!

Please do not post your questions with this form! Thanks.


Name (required)


E-Mail (required)

Your email will not be displayed on the site - only to our administrator
Homepage(optional)



Comment Enable HTML code : Yes No



 
       
         
     
 
 
 
   
 
 
java bottom left
java bottom middle
java bottom right
RSS 0.91 FeedRSS 1.0 FeedRSS 2.0 FeedATOM FeedOPML Feed

Home - About Us - Privacy Policy
Copyright 2005 - 2008 www.java-tips.org
Java is a trademark of Sun Microsystems, Inc.