title: Get fragment in fragment layout android
body: <p>I have an android application with this architecture :</p>
  
  <p>I have an Activity : MainActivity, this one contain a FrameLayout. In this FrameLayout I'm loading a fragment. This one is named Feed. In this Feed Fragment i have a google map fragment. So i want to call getMapAsync on my feed.java but i can't get my map framgment. Don't know how i can do it?</p>
  
  <p>MainActivity.java :</p>
  
  <pre><code>protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
          setSupportActionBar(toolbar);
  
          if(savedInstanceState == null){
              Fragment fragment = null;
              Class fragmentClass = null;
              fragmentClass = Feeds.class;
              this.setTitle("Fil d\'Actualité");
              try {
                  fragment = (Fragment) fragmentClass.newInstance();
              } catch (Exception e) {
                  e.printStackTrace();
              }
  
              FragmentManager fragmentManager = getSupportFragmentManager();
              fragmentManager.beginTransaction().replace(R.id.flContent, fragment).commit();
          }
  </code></pre>
  
  <p>Feeds.java :</p>
  
  <pre><code>@Override
      public void onActivityCreated(@Nullable Bundle savedInstanceState) {
          super.onActivityCreated(savedInstanceState);
          try {
              if (googleMap == null) {
                  SupportMapFragment mF = ((SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.map));
                  mF.getMapAsync(this);
              }
          }
          catch (Exception e) {
              e.printStackTrace();
          }
      }
  </code></pre>
  
  <p>In this code my getChildFragmentManager().findFragmentById(R.id.map) always return null.</p>
  
  <p>I have also tested to write this code on the onCreate event or the onCreateView event but always the same result.</p>
  
  <p>Thanks for your answers!</p>
  
  <p>edit feeds.xml: </p>
  
  <pre><code>    &lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:tools="http://schemas.android.com/tools"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:id="@+id/frameTest"
          tools:context="com.findacomrade.comrade.viewController.fragments.Feeds"&gt;
  
          &lt;!-- TODO: Update blank fragment layout --&gt;
          &lt;TextView
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:text="Fil d'actualité" /&gt;
  
          &lt;fragment
              android:id="@+id/map"
              android:name="com.google.android.gms.maps.MapFragment"
              android:layout_width="match_parent"
              android:layout_height="match_parent"/&gt;
  
      &lt;/FrameLayout&gt;
  
  activity.xml :
  
  &lt;android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:fitsSystemWindows="true"
      tools:context="com.findacomrade.comrade.viewController.MainActivity"&gt;
  
      &lt;android.support.design.widget.AppBarLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:theme="@style/AppTheme.AppBarOverlay"&gt;
  
          &lt;android.support.v7.widget.Toolbar
              android:id="@+id/toolbar"
              android:layout_width="match_parent"
              android:layout_height="?attr/actionBarSize"
              android:background="?attr/colorPrimary"
              app:popupTheme="@style/AppTheme.PopupOverlay" /&gt;
  
      &lt;/android.support.design.widget.AppBarLayout&gt;
  
      &lt;!--&lt;include layout="@layout/content_main" /&gt;--&gt;
      &lt;FrameLayout
          android:id="@+id/flContent"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:layout_marginTop="?attr/actionBarSize"/&gt;
  
  &lt;/android.support.design.widget.CoordinatorLayout&gt;
  </code></pre>