im having a weird problem with Google maps for android.
All is working fine, but when the user starts the activity with the map, i want to zoom in and position the camera on a especified location.
this is my code:
LatLng l = new LatLng(40.446951,-3.693295);
defaultPos = mapa.addMarker(new MarkerOptions().position(new LatLng(l.latitude, l.longitude)).icon(BitmapDescriptorFactory.defaultMarker((float) 250.0)));
Log.d("mappoi","zoom to");
mapa.animateCamera(CameraUpdateFactory.zoomTo(17.0f));
mapa.animateCamera(CameraUpdateFactory.newLatLng(l));
So, as you can see, im creating a new LatLng object and using it to create a Marker on the map, then i want to center camera on that position and zoom in.
I dont know why, but the zoom only works the first time it gets executed, so when i fresh install my app it works fine, but if i go back and restart the activity, it doesnt do any zoom and keeps the default zoom level, even if i close and restart my app it doesnt work anymore, only if i uninstall and reinstall again it works again, but only once.
I cant imagine whats going wrong, if it works first time why not the next?
Thanks for any help.
EDIT: My activity is getting killed when i press back button, so onCreate is called every time.