How to use Fragment in an activity - giving lots of errors : <p>This is the <code>ImageActivity.java</code> </p>

<pre><code>package com.example.app6;

import android.app.FragmentTransaction;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.widget.FrameLayout;

public abstract class ImageActivity extends FragmentActivity {

    private ExampleFragment mFragment;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        FrameLayout frame = new FrameLayout(this);
        if (savedInstanceState == null) {
            mFragment = new ExampleFragment();
            FragmentTransaction ft = getFragmentManager().beginTransaction();
            ft.add(frame.getId(), mFragment).commit();
        }

        setContentView(frame);
    }
}
</code></pre>

<p>and this is <code>ExampleFragment.java</code></p>

<pre><code>package com.example.app6;

import android.app.Activity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;

public class ExampleFragment extends Activity {

    @Override
    public View onCreateView(LayoutInflater inflater,
                             ViewGroup container,
                             Bundle savedInstanceState) {
        Button button = new Button(getActivity());
        button.setText("Hello There");
        return button;
    }
}
</code></pre>

<p>Now both the files are giving me errors. In ExampleFragment, </p>

<blockquote>
  <p>cannot resolve methos 'getActivity()'</p>
</blockquote>

<p>and in ImageActivity, </p>

<blockquote>
  <p>cannot resolve method 'add(int, com.example.app6.ExampleFragment)'</p>
</blockquote>

<p>I am new to Android, thats why I don't have much knowledge about it. Please help me out. Thanks in Advance :)</p>
