BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 05-16-2011, 09:32 AM   #1 (permalink)
Thumbs Must Hurt
 
Join Date: Mar 2011
Model: 8900
PIN: N/A
Carrier: Torch
Posts: 59
Post Thanks: 3
Thanked 1 Time in 1 Post
Default Select Location & draw map

Please Login to Remove!

Hello,

I am j2me api to draw map in such a way that user enter country & map is drawn . my code is

public MyClass(){
selecLocation();
}

public void selectLocation(){
Application.getApplication().invokeAndWait( new Runnable() {

public void run() {
/*try {
final Criteria c = new Criteria();
c.setHorizontalAccuracy(500);
c.setVerticalAccuracy(500);
c.setCostAllowed(false);
c.setPreferredPowerConsumption(Criteria.POWER_USAG E_LOW);
c.setPreferredResponseTime(5000);
lp = LocationProvider.getInstance(c);
} catch (LocationException e) {
Dialog.alert("error");
}*/
if (lp == null) {

lp = LocationProvider.getInstance(null);

}

}
});
if (lp == null) {
Dialog.alert("location not found");
}
else{
lp.setLocationListener(new MyListener(), 5, 1, 1);
}


}

protected void makeMenu(Menu menu, int instance) {

super.makeMenu(menu, instance);
menu.add(new MenuItem("Select Location",1,1) {

public void run() {
try{
MapView _mapv = new MapView();
_mapv.setLatitude((int) (1e5 * lat));
_mapv.setLongitude((int) (1e5 * lng));
;
Invoke.invokeApplication(Invoke.APP_TYPE_MAPS, new MapsArguments(_mapv));
}catch (Exception e) {
Dialog.alert("Error");
}

}
});

}
private class MyListener implements LocationListener
{
public void locationUpdated(LocationProvider provider, Location loc)
{
try{

if(loc.isValid())
{

lat = loc.getQualifiedCoordinates().getLatitude();
lng = loc.getQualifiedCoordinates().getLongitude();
alt = loc.getQualifiedCoordinates().getAltitude();
System.out.println(lat+"\n"+lng+"\n"+alt);


}
}
catch (Exception e) {
Dialog.alert("Cannot find location");
}
}

public void providerStateChanged(LocationProvider provider, int newState) {
// TODO Auto-generated method stub

}
}

Above code was creating map for America & Canada only for other countries it is throwing null pointer exception..

Any body knows why it throws exception for other countries
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads for: Select Location & draw map
Thread Thread Starter Forum Replies Last Post
Maps opens and finds location but no actual map displayed phudson86 General BlackBerry Discussion 4 05-03-2010 02:26 PM
Send GPS position directly to a public Google Map website wesko GPS & Mapping 0 07-22-2008 05:06 PM
Pearl Issues (emails and call logs getting deleted automatically) bacardinole General 8100 Series Discussion - Pearl 35 11-16-2007 12:16 AM
new 8820 report / Yahoo! Go question btaylor1 General Legacy Device Discussion 5 09-23-2007 03:25 PM
7100I Big HELP whoknowswhat General Legacy Device Discussion 1 10-23-2005 03:45 PM

CALIBRATION CALIBRATOR INSTRUMENT -Radio Frequency Laboratory MODEL 829
$699.0
CALIBRATION CALIBRATOR INSTRUMENT -Radio Frequency Laboratory MODEL 829 picture3in1 Portable RF Radio Frequency Slimming Cavitation Body Contour Beauty Device
$60.74
3in1 Portable RF Radio Frequency Slimming Cavitation Body Contour Beauty Device picture5in1 Ultrasonic Cavitation 2.0 Radio Frequency Vacuum Cellulite Machine Fat Loss
$298.0
5in1 Ultrasonic Cavitation 2.0 Radio Frequency Vacuum Cellulite Machine Fat Loss picture3 NOS Corcom 3S1A F1891 EMI Radio Frequency Interference Filter
$9.99
3 NOS  Corcom 3S1A  F1891 EMI Radio Frequency Interference Filter  picture3 NOS CURTIS 8325 F1700AA03 RFI Radio Frequency Interference Filter
$9.99
3 NOS  CURTIS 8325 F1700AA03 RFI Radio Frequency Interference Filter  picture






Copyright 2004-2016 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.