title: Switching from context menu to correct activity
body: <p>My problem is how to switch from context menu to correct activity.</p>
  
  <p>I have such activities:</p>
  
  <ul>
  <li><code>Main</code></li>
  <li><code>AccelerometerOptionsActivity</code></li>
  <li><code>GyroscopeOptionsActivity</code></li>
  <li><code>OrientationOptionsActivity</code></li>
  </ul>
  
  <p>In main activity I have a list of sensors. When I click the sensor, context menu appears where I can click e.g. Options. </p>
  
  <p>My problem is how to switch from context menu to options  activity of chosen sensor. 
  My code:</p>
  
  <pre><code>@Override
      public boolean onContextItemSelected(MenuItem item) {
        AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo)item.getMenuInfo();
        int menuItemIndex = item.getItemId();
        String[] menuItems = getResources().getStringArray(R.array.sensor_array);
        String menuItemName = menuItems[menuItemIndex];
  
  
        if(item.getTitle()=="Start Service"){
            Toast.makeText(this,"Start " + menuItemName+ " selected", Toast.LENGTH_SHORT).show();
        } else if(item.getTitle()=="Stop Service") {
            Toast.makeText(this,"Stop " + menuItemName+ " selected", Toast.LENGTH_SHORT).show();
        } else if(item.getTitle()=="Options") {
  
  
                Intent options = new Intent(this, AccelerometerOptionsActivity.class);
                  startActivity(options);
  
        }
  
        return true;   
      }
  </code></pre>
  
  <p>UPDATE:</p>
  
  <p>Here is the code:</p>
  
  <pre><code> @Override 
      public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { 
           if (v.getId()==R.id.list) {  
              AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo)menuInfo;  
  
              menu.setHeaderTitle(sensorsArray[info.position]);
              menu.add(Menu.NONE, CONTEXTMENU_START, 0,  "Start Service");
              menu.add(Menu.NONE, CONTEXTMENU_STOP, 1,  "Stop Service");
              menu.add(Menu.NONE, CONTEXTMENU_OPTIONS, 2, "Options"); 
              menu.add(Menu.NONE, CONTEXTMENU_GRAPHS, 3, "Graph view");
              menu.add(Menu.NONE, CONTEXTMENU_DATA, 4, "Data view");
           }  
      }
  </code></pre>