title: Android Nested Fragments
body: <p>I'm trying to implement <code>nested fragments</code> but I have a problem.</p>
  
  <p>When I add 2 different <code>fragments</code> with two different <code>tags</code> ("tag1", "tag2") in a <code>ChildFragmentManager</code> of one <code>fragment</code>, everything seems to be ok. </p>
  
  <p>But when I call <code>getChildFragmentManager().findFragmentByTag</code> on these <code>tags</code>, only the first <code>fragment</code> is returned. I'm getting <code>null</code> on the second one. </p>
  
  <p>To add <code>fragments</code> I use:</p>
  
  <pre><code>PersonsImageFragment imf = new PersonsImageFragment(imgPreview, 1);
  android.support.v4.app.FragmentTransaction transaction = frag.getChildFragmentManager().beginTransaction();
  transaction.add(R.id.frame, imf, "tag1")
                          .addToBackStack(tagName)
                          .commit();
  imf = new PersonsImageFragment(imgPreview, 2);
  transaction.add(R.id.frame2, imf, "tag2")
                          .addToBackStack(tagName)
                          .commit();
  </code></pre>
  
  <p>Am I missing something ?</p>
  
  <p><strong>EDIT:</strong> </p>
  
  <pre><code>    f = getChildFragmentManager().findFragmentByTag("tag1");
  //    f.onActivityResult(requestCode, resultCode, data);
      f = getChildFragmentManager().findFragmentByTag("tag2");
   //   f.onActivityResult(requestCode, resultCode, data);
  </code></pre>
  
  <p><strong>EDIT 2:</strong></p>
  
  <p>What I'm trying to do is that, I have <code>ViewPager</code> and in one of the <code>fragments</code> I have <code>custom view</code>, that is responsible for taking a picture and showing it in the <code>ImageView</code>. So the <code>nested fragment</code> is calling <code>camera intent</code> and in <code>onActivityResult</code> it is updating the <code>ImageView</code>. As you know there's a <code>bug</code> in <code>Nested Fragments</code>, I have to call manually the <code>onActivityResult</code> of the <code>nested fragment</code> from the <code>Parent Fragment</code>. So in Parent's <code>onActivityResult</code> I'm trying to get the <code>nested fragment</code> I need and call its <code>onActivityResult</code>.</p>
  
  <p><strong>EDIT 3:</strong></p>
  
  <p>As I said, I have <code>Custom View</code>, that is responsible for taking picture and showing it off. I have 3 <code>Custom Views</code> in the Parent <code>Fragment</code> <code>Layout</code>. And when the user clicks any of them, it should take a picture and preview it. If I add only 1 <code>custom view</code> to the parent <code>fragment</code> it works, but when I use 3  of them, the <code>click event</code> works on all of them, that mean that camera <code>fragment</code> is attached but I can't call <code>onActivityResult</code> on other two because I can't get the <code>fragment</code> that <code>startedActivityForResult</code>, it is <code>null</code>. So the problem, in my opinion, should be in adding <code>nested fragments</code> to <code>transaction</code> but I can't find it.</p>