title: Android Fragment getArguments() returns null
body: <p>As the title suggest.<br>
  I've downloaded <code>Fragment</code> code from here, <a href="http://developer.android.com/shareables/training/FragmentBasics.zip" rel="nofollow noreferrer">http://developer.android.com/shareables/training/FragmentBasics.zip</a>.<br>
  It is Fragment example from <strong>Android Official Developer site</strong>. <a href="http://developer.android.com/training/basics/fragments/fragment-ui.html" rel="nofollow noreferrer">http://developer.android.com/training/basics/fragments/fragment-ui.html</a></p>
  
  <p>This is the <code>MainActivity.java</code>'s <code>onCreate()</code>:</p>
  
  <pre><code>/** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.news_articles);
  
      // Check whether the activity is using the layout version with
      // the fragment_container FrameLayout. If so, we must add the first fragment
      if (findViewById(R.id.fragment_container) != null) {
  
          // However, if we're being restored from a previous state,
          // then we don't need to do anything and should return or else
          // we could end up with overlapping fragments.
          if (savedInstanceState != null) {
              return;
          }
  
          // Create an instance of ExampleFragment
          HeadlinesFragment fragment = new HeadlinesFragment();
  
          // In case this activity was started with special instructions from an Intent,
          // pass the Intent's extras to the fragment as arguments
          //fragment.setArguments(getIntent().getExtras());
          Bundle args= new Bundle();
          args.putString("category", "clothes");
          args.putString("item", "shirts");
          fragment.setArguments(args);
  
          // Add the fragment to the 'fragment_container' FrameLayout
          getSupportFragmentManager().beginTransaction()
                  .replace(R.id.fragment_container, fragment).commit();
      }
  }
  </code></pre>
  
  <p><strong>And <code>HeadlinesFragment.java</code>'s <code>onCreate()</code>:</strong></p>
  
  <pre><code>@Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
      // We need to use a different list item layout for devices older than Honeycomb
      int layout = Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.HONEYCOMB ?
              android.R.layout.simple_list_item_activated_1 : android.R.layout.simple_list_item_1;
  
      Bundle args = getArguments();
      if (args == null) {
          Toast.makeText(getActivity(), "arguments is null " , Toast.LENGTH_LONG).show();
      } else {
          Toast.makeText(getActivity(), "text " + args , Toast.LENGTH_LONG).show();
      }        
  
      // Create an array adapter for the list view, using the Ipsum headlines array
      setListAdapter(new ArrayAdapter&lt;String&gt;(getActivity(), layout, Ipsum.Headlines));
  
  }
  </code></pre>
  
  <p>I've read several QA here, like this one <a href="https://stackoverflow.com/questions/14970790/fragment-getarguments-returns-null">Fragment getArguments() returns null</a>, and many other that related to <code>setArguments()</code> and <code>getArguments()</code>, but still I'm stuck.</p>
  
  <p>And I've moved the <strong><code>Bundle</code></strong> and <strong><code>Toast</code></strong> code to <code>onAttach()</code> and to <code>onCreateView()</code> with no avail. What wrong with the my code? I think I'm missing something, but dunno what is it.<br>
  Please Help! Thanks.</p>
  
  <p><strong>Edit</strong>:<br>
  I'll state my intention more clearly. In FragmentBasic that I downloaded, there's MainActivity.java, HeadlinesFragment.java, and ArticlesFragment.java. The 'communication' from MainActivity.java to ArticlesFragment.java is not the problem here. What I want is to send data from MainActivity.java to HeadlinesFragment.java. Their connection's like this:</p>
  
  <pre><code>--------------------------------------
  | MainActivity &lt;-&gt; HeadlinesFragment |
  |      |                             |
  |      |&gt;&gt; ArticlesFragment          |
  --------------------------------------
  </code></pre>
  
  <p>And <code>HeadlinesFragment</code> is running at Runtime.  </p>
  
  <p>*These code works, when using Android gadget with &lt; 600px width. But doesn't work when using on tablet ( >= 600px), As proved by @Tesla1984 below. But what I want is same result either on gadget &lt; 600px and on gadget > 600px.</p>