06-23-2011, 01:35 AM
|
#4 (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
| Re: Detect Location from GPS I use separate class Location Tracker that create object of Criteria and Location provider in such a way:
Criteria c= new Criteria();
c.setHorizontalAccuracy(Criteria.NO_REQUIREMENT);
c.setVerticalAccuracy(Criteria.NO_REQUIREMENT);
c.setCostAllowed(true);
c.setPreferredPowerConsumption(Criteria.POWER_USAG E_HIGH);
lp= LocationProvider.getInstance(c);
lp.setLocationListener(new MyLocationListener(), 1, 1, 1);
and this is listener code:
private class MyLocationListener implements LocationListener {
public void locationUpdated(LocationProvider provider, Location location)
{
if(location != null && location.isValid())
{
QualifiedCoordinates qc = location.getQualifiedCoordinates();
try {
LocationTracker.this.longitude = qc.getLongitude();
LocationTracker.this.latitude = qc.getLatitude();
} catch(Exception e) {
System.err.println("criccomini " + e.toString()); }
}
else
{
System.err.println("criccomini location not valid");
}
}
I made getter & setter for latitude & longitude in Location Tracker class & call methods of Location Tracker to get latitude & longitude & display on screen. But it shows me values as latitude: 0.0 & longitude: 0.0.
I got this information from net:
By default, if you are using Eclipse with a BlackBerry simulator, it will not have GPS enabled. This is because the default device for the simulator doesn't support GPS. To enable it, you must change the device in the project properties to a BlackBerry device that comes with GPS.
I am currently testing on bold 9700, torch 9800 but it shows me same result
Any one have idea why it gives latitude & longitude as 0.0 |
| Offline
| |