title: Update ViewPager's Fragments from another class:
body: <p>Following this question:</p>
  
  <p><a href="https://stackoverflow.com/questions/16671695/how-to-recreate-all-fragments-in-viewpager">How to recreate all fragments in ViewPager:</a></p>
  
  <p>I have those classes:</p>
  
  <pre><code>public class ViewPagerAdapter extends FragmentPagerAdapter 
  {
  private List&lt;Fragment&gt; fragments;
  
  /**
   * @param fm
   * @param fragments
   */
  public ViewPagerAdapter(FragmentManager fm, List&lt;Fragment&gt; fragments) {
      super(fm);
      this.fragments = fragments;
  }
  
  /* (non-Javadoc)
   * @see android.support.v4.app.FragmentPagerAdapter#getItem(int)
   */
  
  @Override
  public Fragment getItem(int position) {
      return this.fragments.get(position);
  }
  
  /* (non-Javadoc)
   * @see android.support.v4.view.PagerAdapter#getCount()
   */
  
  @Override
  public int getCount() {
      return this.fragments.size();
  }
  
  @Override
  public int getItemPosition(Object object) {
      return POSITION_NONE;
  }  
  }
  </code></pre>
  
  <p>and a <code>FragmentActivity</code>:</p>
  
  <pre><code> public class TabsViewPagerFragmentActivity extends FragmentActivity implements  
   ViewPager.OnPageChangeListener, TabHost.OnTabChangeListener 
   {
      static final String TAG = TabsViewPagerFragmentActivity.class.getSimpleName();
      private TabHost mTabHost;
      private ViewPager mViewPager;
      private HashMap&lt;String, TabInfo&gt; mapTabInfo = new HashMap&lt;String,      TabsViewPagerFragmentActivity.TabInfo&gt;();
      public ViewPagerAdapter mPagerAdapter;
      .....
  </code></pre>
  
  <p>Now in this <code>FragmentActivity</code> I have this listener:</p>
  
  <pre><code>  private class SlicerSelectedOnClickListener implements OnClickListener 
  {
      private ODSharedSlicer slicer;
      private int slicerIndex;
  
      public SlicerSelectedOnClickListener(ODSharedSlicer slicer, int slicerIntex)
      {
          super();
          this.slicer = slicer;
          this.slicerIndex = slicerIntex;
      }
  
      public void onClick(View v) 
      {
          slicerOnClickConfiguration(slicerIndex, v);
          mPagerAdapter.notifyDataSetChanged();
      }
  }
      ....
  </code></pre>
  
  <p>And this works great <code>notifyDataSetChanged()</code> is getting called and the ViewPager's Fragments are getting recreated as I want.</p>
  
  <p><strong>The Problem:</strong> When I try to call the <code>notifyDataSetChanged()</code> method of the adapter from another class (In my case it's a class that responsible to parse data that is received from the server) the fragments remain unchanged.</p>
  
  <p>I tried to do this: I created those methods in my <code>FragmentActivity</code> class (the one with the <code>ViewPager</code>):</p>
  
  <pre><code> public void NotifyTabActivityViewPagerAdapter()
  {
      mPagerAdapter.notifyDataSetChanged();
  }
  
  public ViewPagerAdapter getTabActivityViewPagerAdapter()
  {
      return mPagerAdapter;
  }
  
  public ViewPager getTabActivityViewPager()
  {
      return mViewPager;
  }
  </code></pre>
  
  <p>And tried the following from the second class:</p>
  
  <pre><code>((TabsViewPagerFragmentActivity)currentActivity).NotifyTabActivityViewPagerAdapter();
  </code></pre>
  
  <p>Or:</p>
  
  <pre><code>((TabsViewPagerFragmentActivity)currentActivity).getTabActivityViewPager().setAdapter(((TabsViewPagerFragmentActivity)currentActivity).getTabActivityViewPagerAdapter());
  </code></pre>
  
  <p>But non of this works. Strangely when I run this:</p>
  
  <pre><code>((TabsViewPagerFragmentActivity)currentActivity).getTabActivityViewPager().setAdapter(null);
  </code></pre>
  
  <p>The fragments do get removed, But I can't recreate the new set of fragments with the new data received from server side.</p>
  
  <p>What am I missing here? How should I recreate all the fragment in this <code>FragmentActivity</code> from another class?</p>
  
  <p>Any assistance would be appreciated.</p>