经过30秒后,我如何停止locationoverlay.runonfirsfix?
我认为有一个处理程序,但如何在这个处理程序上实现呢?
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();
}
}
});
没有办法专门阻止这种情况。您可以使用LocationOverlay的onLocationChanged,而不是运行OnFirstFix()。
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);
}
}