在我的应用程序中,我正在地图上绘制路线路径,我正在移动并固定源和目的地。所以我使用 LocationManager 类来获取位置更新myManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,new myLocationListener());
。我走了 10 米的距离,没有完成位置更新。所以为了检查我的代码。我只是将功能放在 onStatusChanged 函数中(因为它至少被调用一次)。我运行应用程序 onStatusChanged 被调用。我的问题是什么pin the source and destination and route drawing class called continuously even though the onStatusChanged is not called
。和pin is not pointed and root is not drawn even though their class is called
。
我的代码:
public class Map extends MapActivity
{
// class for pin the location
class MapOverlay extends com.google.android.maps.Overlay
{
............
Log.e("loc","true");
}
public void onCreate(Bundle savedInstanceState)
{
..................
myManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,new myLocationListener());
}
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
class myLocationListener implements LocationListener {
public void onLocationChanged(Location loc) {
}
........
public void onStatusChanged(String provider, int status, Bundle extras) {
Log.e("MAP","onStatusChanged - called");
....// finding lat and lng getting.
Log.e("Updated Location",""+latPointDst+" , "+lngPointDst);
..........
// here i called MyOverlay class -- root drawing.
// here i called MapOverlay class -- pin the location
}
}
public class MyOverlay extends Overlay {
.............
Log.e("location change","drawing");
}
}
我的日志猫:
05-30 13:29:54.653: ERROR/MAP(3850): onStatusChanged - called
05-30 13:29:54.673: ERROR/Updated Location(3850): 9.909228086471558 , 78.10081958770752
05-30 13:29:54.743: ERROR/loc(3850): true
05-30 13:29:54.783: ERROR/loc(3850): true
05-30 13:29:54.793: ERROR/loc(3850): true
05-30 13:29:54.803: ERROR/loc(3850): true
05-30 13:29:54.813: ERROR/location change(3850): drawing
05-30 13:29:54.983: ERROR/loc(3850): true
05-30 13:29:54.993: ERROR/loc(3850): true
05-30 13:29:54.993: ERROR/loc(3850): true
05-30 13:29:55.003: ERROR/loc(3850): true
05-30 13:29:55.013: ERROR/location change(3850): drawing
05-30 13:29:55.193: ERROR/loc(3850): true
05-30 13:29:55.203: ERROR/loc(3850): true
05-30 13:29:55.223: ERROR/loc(3850): true
05-30 13:29:55.233: ERROR/loc(3850): true
05-30 13:29:55.243: ERROR/location change(3850): drawing
05-30 13:29:55.473: ERROR/loc(3850): true
05-30 13:29:55.483: ERROR/loc(3850): true
05-30 13:29:55.573: ERROR/loc(3850): true
05-30 13:29:55.603: ERROR/loc(3850): true
05-30 13:29:55.633: ERROR/location change(3850): drawing
05-30 13:29:55.693: ERROR/loc(3850): true
等等。我在 statuschanged 内编写类调用,但我不知道如何在不改变状态的情况下连续调用...... 如果我错了,请协助满足我的需要。请帮我。