03-22-2011 05:24 AM
i make appliaction for getting current position,so i use location provider and and get latitude and longitude which values are 0.0
i do not have device.so how i can know that this code is working or not.
please reply .
03-22-2011 08:26 AM
Once you have tested various locations as suggested by the previous poster, I strongly recommend that you get a real device and test your code in it. Real GPS does not behave in the same way as the Simulator, primarily because of the issues with finding satellites (and so the delay in obtaining and accuracy of the data), but also because of the various criteria and types of fixes you can get. So expect to spend some time debugging on a real device before you release your GPS code.
03-22-2011 08:35 AM - edited 03-22-2011 08:37 AM
thanks for reply.
i have one other issue.
when i put below code on buttonclick event ,it show me exception like
getLocation() method cannot be called from event thread
when i use this code without button click it work properly.
so please give me a solution.
locateme=new ButtonField("LOCATE ME",ButtonField.FIELD_LEFT);
public void fieldChanged(Field field,int content)
Criteria criteria = new Criteria();
LocationProvider lp = LocationProvider.getInstance(criteria);
Dialog.alert("GPS is not supported on this platform, exiting...");
if(location!=null && location.isValid())
double longit = location.getQualifiedCoordinates().getLongitude();
double latit = location.getQualifiedCoordinates().getLatitude();
System.out.println("Lat && Long =====> "+longit+" && "+longit);
System.out.println("Exception in Gps===> "+ex.getMessage());
03-22-2011 08:44 AM
Unsurprisingly, this is because you should not call getLocation from the Event Thread!
In fact, the general rule is that you do not call Blocking operations (like network processing, or Thread.sleep() for example) on the Event Thread. The Event Thread is the Thread that processes the User interface processing, like Button Clicks. You block that, your Application is dead as far as your user is concerned. Not good. So is not allowed.
Search for references on the Event Thread for more information on that.
Review GPSDemo code for options to run your getLocation off the Event Thread.
03-22-2011 10:36 AM
I understand your requirement.
But to do this correctly, you need to understand better how to write code for the BlackBerry platform. This will help you in this case and in the future.
Here is a good place to start learning abut the Event Thread.
For more information on GPS in general, try this useful KB article