Hi there Android developers,
I have a question I cannot find anywhere. I have two systems to read a
locaction. One is Skyhook technology, another is the regular GPS.
Anyway sometimes one of the two hangs and when I exit the apllication
the GPS keeps making requests and hangs. I would like to make sure no
matter what, when I leave teh application GPS stops making calls...
Anybody some sample code ? Below is my basic code to get a location
using GPS
lm = (LocationManager)
getSystemService(Context.LOCATION_SERVICE);
locationListener = new MyLocationListener
();
lm.requestLocationUpdates
(LocationManager.GPS_PROVIDER,0,0, locationListener);
}
class MyLocationListener implements
LocationListener
{
public void onLocationChanged(Location
loc) {
if (loc != null) {
try {
mystartlat = Double.toString
(loc.getLatitude());
mystartlon = Double.toString
(loc.getLongitude());
} catch (Exception e) {
/* Display any Error to
the GUI. */
mystart.setText(e.toString);
}
onDestroy();
}
}
@Override
public void onProviderDisabled(String
provider) {
// TODO Auto-generated method stub
}
@Override
public void onProviderEnabled(String
provider) {
// TODO Auto-generated method stub
}
@Override
public void onStatusChanged(String
provider, int status,
Bundle extras) {
// TODO Auto-generated method stub
}
public void onDestroy() {
// unregister location
listener
lm.removeUpdates(locationListener);
}
}
});
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---