Android: When turning the device my application fails in my fragment google maps. Why?

0

Good morning.

My app has a fragment in which inside, it has another fragment of the google map, it works perfect. When turning the device from vertical to horizontal the first time, nothing happens, the application continues to work, but if at the same time I return and turn it I get an error, in the logcat it shows me the following.

android.view.InflateException: Binary XML file line #28: Error inflating class fragment

Obviously it leaves the application, but I have no idea why this happens.

The fragment I'm using for the map is this.

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/map"
        android:name="com.google.android.gms.maps.SupportMapFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context="com.com.mayorgafirm.saxtant.activity.MapsFragment" />

and I'm initializing it on the OnCreateView like this:

googleMap = ((SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.map));
    googleMap.onCreate(savedInstanceState);

How can I solve this?

Thank you in advance.

    
asked by devjav 04.10.2016 в 23:31
source

1 answer

1

Finally! Solved. Remove this line in the onCreateView:

googleMap.onCreate(savedInstanceState); 

And I'm perfect. Thank you very much for your answers.

    
answered by 06.10.2016 в 18:53