Using Interface to implement code on all activities
<p>I am trying to implement some code on every activity and don't want to copy and page the code into each activity. </p>

<p>Originally I just had a parent activity with the code then extended all of the others but I couldn't do this on ListActivities or ExpandableListActivities. </p>

<p>I think this will be done by using an interface class then having each activity implement this.  However when I try to do this Eclipse gives me an error and says to remove the method body. </p>

<p>Here is what I have so far</p>

<pre><code>import android.content.Intent;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.Toast;

public interface MenuOptions {

  /**
     * Method called when the hardware menu button is called. Uses optionmenu.xml for layout
     */
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.optionmenu, menu);
        return true;
    }

    /**
     * Event listener for the options menu. If home is pressed user is sent to home screen. If settings is pressed user is sent to setting screen
     * User is passed as an extra
     */
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        Intent nextIntent = null;

        switch (item.getItemId()) {
            case R.id.home:     
                        Toast.makeText(this, "You pressed the icon!", Toast.LENGTH_LONG).show();
                        nextIntent = new Intent(this, Home.class);

                      break;
            case R.id.settings:     
                        Toast.makeText(this, "You pressed the text!", Toast.LENGTH_LONG).show();
                        nextIntent = new Intent(this, Settings.class);
                      break;

        }

        nextIntent.putExtra("user", user);
        startActivity(nextIntent);
        return true;
    }

}
</code></pre>
