package com.rim.GPSTest;
import javax.microedition.location.Criteria;
import javax.microedition.location.Location;
import javax.microedition.location.LocationException;
import javax.microedition.location.LocationProvider;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.MainScreen;
public class GPSTest extends UiApplication{
public static void main(String[] args) {
GPSTest gps = new GPSTest();
gps.enterEventDispatcher();
}
public GPSTest(){
pushScreen(new GPSTestScreen());
}
}
final class GPSTestScreen extends MainScreen{
LocationProvider provider;
Location location;
public GPSTestScreen() {
Criteria c = new Criteria();
c.setCostAllowed(false);
c.setHorizontalAccuracy(50);
c.setVerticalAccuracy(50);
try {
provider = LocationProvider.getInstance(c);
location = provider.getLocation(-1);
} catch (LocationException e) {
Dialog.inform("Location Exception");
e.printStackTrace();
} catch (Exception e) {
Dialog.inform("Exception");
e.printStackTrace();
}
add(new LabelField("location: "+Double.toString(location.getQualifiedCoordinates().getLatitude())));
add(new LabelField("location: "+Double.toString(location.getQualifiedCoordinates().getLongitude())));
}
}
Hi this is a nice Blog i like this.
ReplyDeletei am using this code for get current lat and long but it is display 0.0 and i m not getting any result. i am doing app in 5.0 version. if you have any idea then send me plz..and i have to display multiple location (pin) in Google Map. you you have idea regarding my problem plz help....