Hey guys
I am trying to build an app that gets the users current GPS coordinates if they have GPS available. I have a simple function that returns a comma separated string lat,lng like this:
Criteria cr = new Criteria();
cr.setHorizontalAccuracy(500);
LocationProvider lp = LocationProvider.getInstance(cr);
Location loc;
if (lp.getState()==LocationProvider.AVAILABLE)
{
try {
loc = lp.getLocation(30);
Coordinates c = loc.getQualifiedCoordinates();
double lat = c.getLatitude();
double lng = c.getLongitude();
ret = lat + "," + lng;
} catch (InterruptedException ex) {
ret = "Not available";
} catch (LocationException ex) {
ret = "Not available";
}
}
else
{
ret = "Not available";
}
return ret;
Thats all good and well, but on my app when I call that function, it asks me if I want to allow the app to use Positioning data, I click yes, and coz I dnt have GPS it times out and says not available. But then it asks me again with the same outcome. And if i click no, it just asks me again. So it gets stuck in a continuous loop of checking.
Any ideas why it is doing this and how I can check if gps is available or not only 1?
Thanks for any help or feedback

Reply With Quote



