如何在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();
}
}
});
答案 0 :(得分: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);
}
}