title: Call Fragment method from activity using FragmentPagerAdapter
body: <p>Originally I had a single fragment loaded in my <code>MainActivity</code>class. I used the following in </p>
  
  <blockquote>
    <p>onCreate</p>
  </blockquote>
  
  <pre><code> if (savedInstanceState == null) {
              getSupportFragmentManager().beginTransaction()
                      .add(new TimeTableFragment(), TIMETABLEFRAGMENT_TAG)
                      .commit();
          }
  </code></pre>
  
  <p>and in </p>
  
  <blockquote>
    <p>onResume</p>
  </blockquote>
  
  <pre><code>if(*setting has changed*){
   TimeTableFragment tf = (TimeTableFragment) getSupportFragmentManager()
                      .findFragmentByTag(TIMETABLEFRAGMENT_TAG);
              if (null != tf) {
                  tf.onStudentIdChanged();
              }
  }
  </code></pre>
  
  <p>The <code>onStudentIdChanged()</code> method would refresh the fragment data as preference settings have changed.</p>
  
  <p>I have now refactored this activity to use <code>FragmentPagerAdapter</code>and load two different fragments in tabs. Both fragments are instances of the same <code>TimetableFragment</code> class, but with different parameters passed when creating.</p>
  
  <blockquote>
    <p>FragmentPagerAdapter methods</p>
  </blockquote>
  
  <pre><code>@Override
      public Fragment getItem(int position) {
          // getItem is called to instantiate the fragment for the given page.
          // Return a Fragment
          switch (position) {
              case 1:
              case 2:
                  return TimeTableFragment.newInstance(position);
              case 0:
                  //todo add the single day here
                  return TimeTableFragment.newInstance(position);
          }
          return null;
      }
  </code></pre>
  
  <blockquote>
    <p>TimetableFragment Method</p>
  </blockquote>
  
  <pre><code> public static TimeTableFragment newInstance(int sectionNumber) {
          TimeTableFragment fragment = new TimeTableFragment();
          Bundle args = new Bundle();
          args.putInt(ARG_SECTION_NUMBER, sectionNumber);
          fragment.setArguments(args);
          return fragment;
      }
  </code></pre>
  
  <p>Now that this is working, in <code>onResume</code> of my <code>MainActivity</code>I am no longer able to access the Fragments using <code>findFragmentByTag</code>, as they are not added in this way during <code>onCreate</code>and I can no longer call the <code>onStudentIdChanged</code> method.</p>
  
  <p>How, for all created instances of the Timetable Fragment can I call this method and have the data updated / refreshed?</p>