Location Api



Share on Google+Share on Google+

Location Api
0 Answer(s)      7 years ago
Posted in : MobileApplications
I am using following code to get coordinates of location in gps.
On emulator in netbeans it shows me output as

2.0 2.0
but on real mobile it doesrnt give me any help:

package com.tutorial;
import javax.microedition.location.*;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
//import net.jscience.util.MathFP;
public class HelloMap
extends MIDlet
implements CommandListener {
private Form mMainForm;
public HelloMap() {
mMainForm = new Form("Hello map");
mMainForm.append(new StringItem(null, "Hello, map!\n"));
mMainForm.addCommand(new Command("Exit", Command.EXIT, 0));
// First Set criteria for selecting a location provider:
Criteria cr= new Criteria();

public void startApp() {
cr.setHorizontalAccuracy(500); // accurate to 500 meters horizontally

try {
// Now get an instance of the provider
LocationProvider lp= LocationProvider.getInstance(cr);

// Request the location, setting a one-minute timeout
Location l = lp.getLocation(2);
Coordinates c = l.getQualifiedCoordinates();

if(c != null ) {
// Get coordinate information
double lat = c.getLatitude();
double lon = c.getLongitude();


} catch (Exception e) {

public void pauseApp() {}

public void destroyApp(boolean unconditional) {}

public void commandAction(Command c, Displayable s) {

Please help.
View Answers

Related Tutorials/Questions & Answers:
Location Api - MobileApplications
Location Api  I am using following code to get coordinates of location in gps. On emulator in netbeans it shows me output as 2.0 2.0... a location provider: Criteria cr= new Criteria(); public void
Location Reminder
Location Reminder  Hi, i am planing to do a project called location... mark thar place in my mobile, and later if i visit that location,my mobile has to give a reminder. How to mark a location on mobile using GPS? Please give me
cursor location
cursor location   hi,please how to change cursor location by java code ,i use this code but not change the location JTextArea a=new JtextArea(); if(resultText.equalsIgnoreCase("class")){ a.append("a { \n }"); PointerInfo
location - MobileApplications
location  I want to do project in which when i go to college my mobile should get automatically to silent mode using the location where the college... location that come on our mobile display and silent the mobile. im new to J2ME
mkmapkit location search
mkmapkit location search  How to create a location search function that will allow the current location search on the MKMapKit
iphone location framework
iphone location framework  Which framework do i need to add to get the iphone current location in iPhone frameworks?   Add core location to your existing frameworks. CoreLocation.framework   
mkmapview zoom to current location
mkmapview zoom to current location  How can i zoom map to the current location
Find Exact Location from IP address in java?
Find Exact Location from IP address in java?  I am looking for API where we can pass IP address and get the location (Cityname,Country name). please suggest any API OR sample code. Thank you
j2me location updates programming
j2me location updates programming  kindly please, assist me with with a j2me code for obtaining and sending GPS location updates periodicaly to the server IE; LATITUDE, LONGITUDE, SPEED, TIME. Am using netbeans IDE and PHP
neo4j-server.properties file location
neo4j-server.properties file location  Hi, Where is the location of neo4j-server.properties file in Linux? Thanks   Hi, Location of neo4j-server.properties file: This file is present in /etc/neo4j directory of linux
Remote Location Handeling - RMI
Remote Location Handeling  I have application where I want main control from one location and have to connect two more locations remotly and have... location
timezone_location_get() Function in PHP timezone_location_get alias DateTimeZone::getLocation returns location information for a timezone including country code, latitude/longitude and comments. Syntax of timezone_location_get
Automatic Vehicle Location Advantage,Automatic Vehicle Location,Vehicle Location
Automatic Vehicle Location Advantage     ... Location or AVL is a system primarily used in tracking vehicles, freight... Better security for driver as well as travelers by enabling faster location
Version of cn.featherfly>location-lookup dependency
List of Version of cn.featherfly>location-lookup dependency
JavaScript method location
JavaScript method location         ... using location property of the window object. One of them is location.href which
Program in javascript to show the current location
Program in javascript to show the current location  Hi All, Actually in my application ..i wanted to updated the current location each time it gets... location in JavaScript? Thanks
Java Get Class Location
Java Get Class Location   ... location. For this, we have used the classes URL and ClassLoader. The class...(classLocation) returns the location of the class.  import 
what is hibernate dtd file location
what is hibernate dtd file location  Hi, I am trying to find dtd of Hibernate online but not able to find. what is hibernate dtd file location Thanks
File location in FileOutputStream - JSP-Servlet
File location in FileOutputStream  Hai, For uploading a file i... a method to specify a location to store the file which is uploaded. I required...\webapps\mca2006sfssjc.co.in\stud\images by changing the location to the folder
Struts properties file location - Struts
Struts properties file location  Hi, Where struts properties file stored in web application. I mean which location. Thank u   Hi Friend, The struts.properties file can be locate anywhere on the classpath
Location finding error - JSP-Servlet
Location finding error  Location needs from drive name: My file uploading program has an error. It requires the location should be given from the directory name. Instead of this if only parent directory is given it shows
Project Location change - Development process
Project Location change  Hi , I have developed mini project . In my machine everything is working fine. But i moved that folder to another machine ,ow can i run that project. Now i installed weblogic in tat system also
Google Map get Current Location on iphone and Android phones
Google Map get Current Location on iphone and Android phones  Hi, I am writing a simple javascript to get longitude and latitude for current location by using google API , but it works in my desktop browser but it doesn't
Maven Dependency location-lookup >> 1.0.0
You should include the dependency code given in this page to add Maven Dependency of cn.featherfly >> location-lookup version1.0.0 in your project
Version of com.moengage>moe-location-lib dependency
List of Version of com.moengage>moe-location-lib dependency
Version of com.moengage>moe-location-lib dependency
List of Version of com.moengage>moe-location-lib dependency
API  what means API in java?   Hi Friend, The Application Programming Interface (API) is a library of functions that allow programmers... for building software applications in java. If you want to know about java api, please
How to downloads an application of the file from remote location?
How to downloads an application of the file from remote location?  Hi... location? Thanks,   Hi, As per your query i fell this example... an application of file in the remote location. Plz visit this link for how to download
api  WHAT IS THE DEFINITON OF API,EXPLAIN IN DETAIL?   An API is the interface implemented by an application which allows other... of it by a computer program. An API differs from an application binary interface
Getting Latitude and longitude from GPS location?
Getting Latitude and longitude from GPS location?  I want to get longitude and latitude from GPS location. I want to find the distance between the two places(Example: Delhi and Mumbai). If I get Latitude and longitude
to make a google map point to user defined location
) and points the location in google map.so how do i do it? wen i press the submit... the desired location of the user


Advertisement null