【发布时间】:2011-12-09 15:39:03
【问题描述】:
我对 Android 中的 onLocationChanged 事件有疑问。这是触发:
case R.id.start: {
Points.add(overlay.getMyLocation()); // Points' type is ArrayList<GeoPoint>
mgr.requestLocationUpdates(best, 0, 3, locationListener);
}
break;
这里是 onLocationChanged 方法:
public void onLocationChanged(Location location) {
i++;
Points.add(overlay.getMyLocation());
MapOverlay mapOverlay = new MapOverlay(Points.get(i-1), Points.get(i));
map.getOverlays().add(mapOverlay); //does the drawing
mMapController.animateTo(Points.get(i));
}
因此,onLocationChanged 仅在我按下“开始”后才被调用一次。它应该在每次位置发生变化时自动调用,对吧?在我的情况下,它不是。
请帮帮我。
【问题讨论】:
-
您是否将使用位置服务的权限添加到清单中,如下所示:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>? -
当然,这是我的权限部分:
-
虽然已经很晚了但是希望这个评论可以帮到别人,看看这个链接:lengrand.fr/2013/10/…
标签: android geolocation gps locationmanager locationlistener