Search code examples
androidscreen-rotation

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.


Solution

  • 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.