Marker does not implement Parcelable
, Serializable
interfaces, but i need to persist it between Activity onPause
/onResume
, so how can i persist it? How can i get all current Markers list (can't find getMarkers() method anywhere)?
Imagine the next case: i have added Marker
and started AsyncTask
to perform long-running task and update view for the Marker. Task is in progress and i change orientation, activity is recreated. How can i update that Marker after Task is finished? Let's imagine i can persist id of the Marker and Markers are saved by fragment automatically (just imagine), then how can i find it using id after activity is recreated?
You can persist MarkerOptions
objects because they are Parcelable
and then recreate Marker
objects from them.
Marker
s are not part of the "UI state" and hence shouldn't be saved/restored on configuration change.
On configuration change, you will simply recreate all Marker
s using the exact same code you used to populate the GoogleMap
the first time it has been displayed.
If you really want to persist them (which is a really bad idea from my point fo view), this is still possible by doing so manually in onSaveInstance(Bundle outState)
Edit: See "Deep Dive Into Android State Restoration"
it seems that there is no way to do this now: http://code.google.com/p/gmaps-api-issues/issues/detail?id=4650
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With