title: How can getArguments() be called in onCreate() of a Fragment..?
body: <p>Can someone explain how <code>setArguments()</code> works? I don't get it. I get how to use it, but I don't really understand how the code below can actually work:</p>
  
  <pre><code>public class MyDialogFragment extends DialogFragment{
  
      public static MyDialogFragment newInstance(String test) {
          MyDialogFragment f = new MyDialogFragment();
  
          Bundle args = new Bundle();
          args.putString("test", test);
          f.setArguments(args);
  
          return f;
      }       
  
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          Log.d("DEBUG", getArguments().getString("test")); // This actually works!
      }
  
  }
  </code></pre>
  
  <p>I would have thought that <code>onCreate()</code> got called before the call to <code>setArguments()</code>, but clearly it does not. Is this the way it is supposed to work, or is it just pure luck that the call to <code>setArguments()</code> gets executed before <code>onCreate()</code> on my particular device? Could the opposite happen under different circumstances (faster/slower/different device, etc.)?</p>
  
  <p>Maybe someone can point me to an article that describes how the flow of events for this works? I don't see where <code>onCreate()</code> would get called in the code above, unless it is called asynchronously, which to me sounds like it would be risky to rely on <code>getArguments()</code> inside <code>onCreate()</code>...</p>