首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >停止myLocationOverLay.runOnFirstFix

停止myLocationOverLay.runOnFirstFix
EN

Stack Overflow用户
提问于 2012-07-12 02:10:02
回答 1查看 447关注 0票数 1

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

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

代码语言:javascript
复制
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();
                           }
                     }

               });
EN

回答 1

Stack Overflow用户

发布于 2013-05-10 06:27:12

没有办法明确地阻止这一点。您可以使用LocationOverlay的onLocationChanged代替runOnFirstFix()。

代码语言:javascript
复制
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);
    }

}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11438769

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档