Default fragment on Activity Launch
<p>I'm trying to have a fragment loaded as the default view for the activity, but I just get a blank screen and huge memory leaks.</p>

<p>Activity file <code>onCreate</code> method:</p>

<pre><code>@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_login);

    if (savedInstanceState == null) {
        FragmentManager fragmentManager = getFragmentManager();
        int fragmentTransaction = fragmentManager.beginTransaction()
                .add(R.id.login_screen_fragment, new FragmentLogin())
                .commit();
    }
}
</code></pre>

<p>The XML for the activity:</p>

<pre><code>&lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".LoginActivity"&gt;

    &lt;fragment
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/login_screen_fragment"
        class="com.test.project.FragmentLogin"
    /&gt;

    &lt;fragment
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/forgotten_password_fragment"
        class="com.test.project.FragmentForgottenPassword"
    /&gt;
&lt;/FrameLayout&gt;
</code></pre>

<p>And the Fragment class (relevant parts):</p>

<pre><code>@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    final View view = inflater.inflate(R.layout.fragment_login, container, false);
    final Activity activity = getActivity();

    ... code ...

    return view;
}
</code></pre>

<p>I followed instructions from a tutorial someone suggested earlier from a different question, but I must be doing something horribly wrong. Any ideas?</p>