Wednesday, May 4, 2011

[android-developers] LocationManager and MyLocationOverlay

Hello.
When booting I get the card user's location on the map:
private MapView mapView;
private MapController mapController;
private MyLocationOverlay myLocationOverlay;
private LocationManager mLocationManager;
private LocationListener mLocationListener;

mapController = mapView.getController();
initMap();
mapController.setZoom(18);
mapView.setClickable(true);
mapView.setEnabled(true);
mapView.setSatellite(false);}

private void initMap() {
myLocationOverlay = new MyLocationOverlay(this, mapView);
mapView.getOverlays().add(myLocationOverlay);
myLocationOverlay.enableCompass();
myLocationOverlay.enableMyLocation();
myLocationOverlay.runOnFirstFix(new Runnable() {
public void run() {

mapController.animateTo(myLocationOverlay.getMyLocation());
}
});
How can I update the data after some time. I do so, but it does not
work.
mLocationManager = (LocationManager)
this.getSystemService(Context.LOCATION_SERVICE);
mLocationListener = new LocationListener() {
public void onLocationChanged(Location location) {

makeUseOfNewLocation(location);
}

public void onStatusChanged(String provider, int status, Bundle
extras) {}

public void onProviderEnabled(String provider) {}

public void onProviderDisabled(String provider) {}
};

mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,
0, 0, locationListener);

mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
0, 0, locationListener);
What I am doing no wrong?

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate