D: So, I have seen two general practices to instantiate a new Fragment in an application:
Fragment newFragment = new MyFragment();
and
Fragment newFragment = MyFragment.newInstance();
The second option makes use of a static method newInstance() and generally contains the following method.
public static Fragment newInstance()
{
MyFragment myFragment = new MyFragment();
return myFragment;
}
At first I though the main benefit was the fact that I could overload the newInstance() method to give flexibility when creating new instances of a Fragment - but I could also this by creating an overloaded constructor for the Fragment.
The question from myself (and others in my city) have we missed something? What are the benefits of one approach over the other - or is it just good practice? Any input I would be thankful for.