1

经过 30 秒后,如何停止 locationoverlay.runonfirstfix?

我认为有一个处理程序,但如何实现呢?

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();
                           }
                     }

               });
4

1 回答 1

0

没有办法专门阻止这种情况。您可以使用 LocationOverlay 的 onLocationChanged 而不是 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);
    }

}
于 2013-05-09T22:27:12.287 回答