title: Adding the same context menu to multiple activities
body: <p>I'm trying to figure out how to include common pieces of code in multiple activities.</p>
  
  <p>More specifically, I have a context menu that I would like to include in several activities.
  I saw this, but just don't understand how to extend to multiple activities.
  <a href="http://developer.android.com/guide/topics/ui/menus.html" rel="noreferrer">http://developer.android.com/guide/topics/ui/menus.html</a></p>
  
  <p>I have this set up as Menu.java</p>
  
  <pre><code>    public class Menu extends Activity{
  
      // bottom menus
      public static final int Menu1 = 1;
      public static final int Menu2 = 2;
      public static final int Menu3 = 3;
      public static final int Menu4 = 4;
      public static final int Menu5 = 5;
      public static final int Menu6 = 6;
      public static final int Menu7 = 7;
  
  
      // / Creates the menu items
      public boolean onCreateOptionsMenu(Menu menu) {
  
          menu.add(0, Menu3, 0, "Create Profile").setIcon(
                  this.getResources().getDrawable(R.drawable.ic_menu_add));
          menu.add(0, Menu5, 0, "Log In").setIcon(
                  this.getResources().getDrawable(R.drawable.ic_menu_login));
          menu.add(0, Menu2, 0, "Settings").setIcon(
                  this.getResources().getDrawable(R.drawable.ic_menu_preferences));
          menu.add(0, Menu4, 0, "About").setIcon(
                  this.getResources().getDrawable(R.drawable.ic_menu_help));
          menu.add(0, Menu1, 0, "Report A Bug").setIcon(
                  this.getResources().getDrawable(R.drawable.ic_menu_start_conversation));
          menu.add(0, Menu6, 0, "New Stuff").setIcon(
                  this.getResources().getDrawable(R.drawable.ic_menu_view));
          return true;
      }
  
  
  
      private MenuItem add(int i, int menu32, int j, String string) {
          // TODO Auto-generated method stub
          return null;
      }
  
  
  
      // Handles item selections from preference menu
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
          switch (item.getItemId()) {
          case Menu1:
              startActivity(new Intent(this, Bug.class));
              return true;
          case Menu2:
              startActivity(new Intent(this, EditPreferences.class));
              return true;
          case Menu3:
              startActivity(new Intent(this, CreateAccount.class));
              return true;
          case Menu4:
              startActivity(new Intent(this, About.class));
              return true;
          case Menu5:
              startActivity(new Intent(this, Login.class));
              return true;
          case Menu6:
              startActivity(new Intent(this, NewAdditions.class));
              return true;
          }
  
          return false;
      }
  
  
  }
  </code></pre>