title: Passing objects in to Fragments
body: <p>I've been working with lots of <code>Fragments</code> recently and have been using two distinct methods of passing in objects to the Fragments, but the only difference that I can see is that in the approach taken by FragmentOne below, the object you pass in must implement the <code>Serializable</code> interface (<a href="http://www.javapractices.com/topic/TopicAction.do?Id=45">and everything associated with that</a>).  </p>
  
  <p>Are there any benefits to using one over the other?</p>
  
  <pre><code>public class FragmentOne extends Fragment {
      public static final String FRAGMENT_BUNDLE_KEY = 
          "com.example.FragmentOne.FRAGMENT_BUNDLE_KEY";
  
      public static FragmentOne newInstance(SomeObject someObject) {
          FragmentOne f = new FragmentOne();
          Bundle args = new Bundle();
          args.putSerializable(FRAGMENT_BUNDLE_KEY, someObject);
          f.setArguments(args);
          return f;
      }
  
      public SomeObject getSomeObject() {
          return (SomeObject) getArguments().getSerializable(FRAGMENT_BUNDLE_KEY);
      }
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>public class FragmentTwo extends Fragment {
      SomeObject mSomeObject;  
  
      public static FragmentTwo newInstance(SomeObject someObject) {
          FragmentTwo fragment = new FragmentTwo();
          fragment.setSomeObject(someObject);
          return fragment;
      }
  
      public void setSomeObject(SomeObject someObject) {
          mSomeObject = someObject;
      }
  }
  </code></pre>