21.04.2014 Views

Curso-Android-Desarrollo-de-Aplicaciones-Móviles

Curso-Android-Desarrollo-de-Aplicaciones-Móviles

Curso-Android-Desarrollo-de-Aplicaciones-Móviles

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CURSO ANDROID<br />

71<br />

MapView mapView = (MapView) findViewById(R.id.mapview);<br />

//habilitamos el control <strong>de</strong> zoom<br />

mapView.setBuiltInZoomControls(true);<br />

LocationManager locationManager =<br />

(LocationManager)getSystemService(Context.LOCATION_SERVICE);<br />

updateLocation(locationManager.getLastKnownLocation(LocationManager.GPS_<br />

PROVIDER));<br />

/* se actualizará cada minuto y 50 metros <strong>de</strong> cambio en la localización<br />

mientras más pequeños sean estos valores más frecuentes serán las<br />

actualizaciones */<br />

locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 6000, 50,<br />

this);<br />

Luego en el método onLocationChanged llamamos a nuestro método updateLocation para que dibuje<br />

un nuevo marker cada vez que se actualice la localización:<br />

@Overri<strong>de</strong><br />

public void onLocationChanged(Location location) {<br />

updateLocation(location);<br />

}<br />

http://www.foros<strong>de</strong>lweb.com/f165/<br />

https://github.com/androidMDW/guia5completo

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!