Quote:
Originally Posted by xmncxzvt
I am using this autonomous mode with following criteria . I have set interval of 5 minutes so it obtain first location after 5 mins.
I have make separate thread which sleeps for 5 mins (inorder to get first location after first fix) But even after that when i get latitude & longitude it shows 0.0
Criteria c = new Criteria();
c.setHorizontalAccuracy(50);
c.setVerticalAccuracy(50);
c.setCostAllowed(true);
c.setPreferredPowerConsumption(Criteria.POWER_USAG E_MEDIUM);
try {
lp = LocationProvider.getInstance(c);
} catch (LocationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
lp.setLocationListener(new MyLocationListener(),300, 10,30);
|
Have a look at this
sticky thread on posting code. It makes reading your code much easier:
Code:
Criteria c = new Criteria();
c.setHorizontalAccuracy(50);
c.setVerticalAccuracy(50);
c.setCostAllowed(true);
c.setPreferredPowerConsumption(Criteria.POWER_USAGE_MEDIUM);
try {
lp = LocationProvider.getInstance(c);
} catch (LocationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
lp.setLocationListener(new MyLocationListener(),300, 10,30);
The quality of an autonomous fix is going to depend on the quality of the signal you receive. First, try not setting accuracy requirements. Also, if you are using a location listener, you don't need to have a thread sleep for 5 minutes, the listener will only be called at the interval you select. In this case 5 minutes.
You may also want to read the documentation for setLocationListener, and pay particular attention to the paragraphs on timeout and maxAge. I don't know what your requirements are, but having an interval of 300 but a timeout of 10 and max age of 30 don't make much sense in most cases. What you're saying is give me a position every 300 seconds, but has to have an hdop and vdop of bettern than 50 meters, can't be more than 30 seconds old (at the time it is delivered), and only wait for 10 secods for a new position if one isn't available. I suspect the locations you are getting also have the valid flage set to false.