title: Unable to pass data from MainActivity to ViewPager Fragments
body: <p>In my Android program, I've three <code>Fragments</code> wrapped in a <code>ViewPager</code>. I have an <code>ArrayList&lt;MyObject&gt;</code> which is filled inside the <code>onResume()</code> method of the <code>MainActivity</code>. How can I send this <code>ArrayList&lt;MyObject&gt;</code> from the <code>MainActivity</code> to child <code>Fragments</code>? What I want is to update my fragment with the <code>ArrayList&lt;MyObject&gt;</code>, whenever the app comes to foreground.
  There are a lot of solutions for this specific problem, but none of them is working for me. I've already tried using <code>Bundles</code> to pass arguments to my <code>Fragments</code>. For testing, I'm trying to pass simple int value to child fragment:
  In the <code>onCreate()</code> of <code>MainActivity</code>:</p>
  
  <pre><code>Bundle bundle = new Bundle();
  bundle.putInt("INTEGER",2);
  </code></pre>
  
  <p>In the <code>onResume()</code> of <code>MainActivity</code>:</p>
  
  <pre><code>Fragment frag = MyFragPageAdapter.getItem(1);
  frag.setArguments(bundle);
  </code></pre>
  
  <p>In the <code>onCreate()</code> method of my <code>Fragment</code>:</p>
  
  <pre><code>final Bundle args = getArguments();
  final int myInt = args.getInt("INTEGER");
  Log.v("IN FOREGROUND", myInt+"");
  </code></pre>
  
  <p>Can anyone please help me? Thanks in advance!</p>
  
  <p>Adapter:</p>
  
  <pre><code>public class MyFragPageAdapter extends FragmentPagerAdapter implements IconTabProvider {
  
      private final int[] ICONS = { R.drawable.ic_action_cc_bcc, R.drawable.ic_action_call, 
              R.drawable.ic_action_chat};
      private final String[] tabTitles = {"Contacts", "Calls", "Messages" };
  
      public FragmentPageAdapter(FragmentManager fm) {
          super(fm);
      }
  
      @Override
      public Fragment getItem(int arg0) {
          switch (arg0) {
          case 0:
              return new ContactList();
          case 1:
              return new DialPad();
          case 2:
              return new BlockedList();
          default:
              break;
          }
  
          return null;
      }
  
      @Override
      public int getCount() {
          return 3;
      }
  
      @Override
      public int getPageIconResId(int position) {
          // TODO Auto-generated method stub
          return ICONS[position];
      }
  
      /* (non-Javadoc)
       * @see android.support.v4.view.PagerAdapter#getPageTitle(int)
       */
      @Override
      public CharSequence getPageTitle(int position) {
          // TODO Auto-generated method stub
          return tabTitles[position];
      }
  </code></pre>