Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - don't refresh Google Maps v2 on rotation

When I rotate my device, Google Maps v2 refreshes. How do I prevent this refresh from occurring? I'm adding the map dynamically in a tab of a SherlockFragment.

like image 228
Anonymous1 Avatar asked Dec 15 '13 00:12

Anonymous1


1 Answers

I fixed the problem by adding to the Activity in AndroidManifest.xml:

android:configChanges="orientation|screenSize"

Edit (04/28/2017) :

From the Android Documentation:

Note: Using this attribute should be avoided and used only as a last resort. Please read Handling Runtime Changes for more information about how to properly handle a restart due to a configuration change.

Maybe you could look at this answer, which properly saves the SupportMapFragment using the Bundle available in the onCreate method of FragmentActivity.

like image 62
Anonymous1 Avatar answered Sep 18 '22 13:09

Anonymous1