Reputation: 12346
how can i stop the locationoverlay.runonfirstfix when pass 30 seconds?
I think with a handler but how can implement that on this?
miPunto.runOnFirstFix(new Runnable()
{
@Override
public void run()
{
if (miPunto.getMyLocation() != null)
{
latitud = miPunto.getMyLocation().getLatitudeE6();
longitud = miPunto.getMyLocation().getLongitudeE6();
gmiPunto = new GeoPoint((int) (latitud), (int) (longitud));
controladorMapa.animateTo(gmiPunto);
controladorMapa.setZoom(17);
controladorMapa.setCenter(gmiPunto);
dialogo.dismiss();
}
}
});
Upvotes: 1
Views: 512
Reputation: 3409
There is no way to specifically stop this. You can use LocationOverlay's onLocationChanged instead of runOnFirstFix().
public void onResume() {
super.onResume();
if (locationOverlay == null) {
locationOverlay = new JulietLocationOverlay(mapView);
}
mapView.getOverlays().add(locationOverlay);
locationOverlay.enableMyLocation();
}
public void onPause() {
super.onPause();
if (locationOverlay != null) {
if (mapView != null) {
mapView.getOverlays().remove(locationOverlay);
}
locationOverlay.disableMyLocation();
}
}
protected class JulietLocationOverlay extends MyLocationOverlay {
public boolean locationFound = false;
public synchronized void onLocationChanged(Location location) {
super.onLocationChanged(location);
if (!locationFound) {
// As good as first fix.
// Do every thing you need
}
}
public JulietLocationOverlay(MapView mapView) {
super(Activity.this, mapView);
}
}
Upvotes: 0