Location is not updated with new geo fix in android emulator

I am trying to make MapView zoom to the current location based on GeoPoint. I set the location using the geo fix command in telnet. My problem is that when I first enter a place using geo fix, my code will move correctly to the location on the map. If I try to install another location using geo fix, it will not be updated. Here is the code to update:

public void updateLocation(Location loc) { p = new GeoPoint((int)(loc.getLongitude() * 1E6),(int)(loc.getLatitude() * 1E6)); mc = mapView.getController(); mc.animateTo(p); } 

and here is my code to call the update:

 LocationListener onLocationChange=new LocationListener() { public void onLocationChanged(Location location) { updateLocation(location); } 

etc...

I have the following in onResume ():

  super.onResume(); myLocationManager.requestLocationUpdates("gps", 0, 200, onLocationChange); 

The points I'm trying to set geo are far enough apart to meet the minimum distance requirements. Anyone have any ideas on what I am missing?

0
source share
2 answers

Call mapView.invalidate(); (see View: invalidate () ) or mapView.postInvalidate(); (see View: postInvalidate () ), depending on whether it works in the UI thread or not, after

 mc.animateTo(p); 
+3
source

Assuming MapActivity implements a LocationListener, change

 myLocationManager.requestLocationUpdates("gps", 0, 200, onLocationChange); 

to

 myLocationManager.requestLocationUpdates("gps", 0, 200, this); 

'this' contains the location receiver

0
source

All Articles