title: Android NULL menuInfo in onCreateContextMenu and onContextItemSelected only with manual call to openContextMenu in onListItemClick. Long click works
body: <p>I have parsed through a lot of the posts here and haven't found anything quite like my problem.</p>
  
  <p>Basically I am trying to call <code>openContextMenu(l)</code> in <code>onListItemClick</code>.  Doing so creates a context menu with no <code>menuInfo</code>.  Performing a long click will work correctly.  After the long click is performed, my code will start working and actually get a <code>menuInfo</code> that is not null.</p>
  
  <p>I have a <code>ListActivity</code> that is filled with a <code>SimpleCursorAdapter</code> which grabs data from <code>SQL</code>.</p>
  
  <p>In my onCreate I <code>registerForContextMenu(getListView())</code>.
  I have also tried using <code>registerForContextMenu(l)</code> just before the <code>openContextMenu(l)</code> call.</p>
  
  <p>Any help would be appreciated!  Thanks.</p>
  
  <p>Here is a sample of my code:</p>
  
  <pre><code>public class MY_Activity extends ListActivity {
  
  ...
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
  
      ...
  
      UpdateTable();
      registerForContextMenu(getListView());
  }
  
  ...
  
  @Override
  public void onListItemClick(ListView l, View view, int position, long id) {
      super.onListItemClick(l, view, position, id);
  
      //THIS DOESNT WORK UNLESS A LONG CLICK HAPPENS FIRST
      //registerForContextMenu(l);  //Tried doing it here too
      openContextMenu(l);
      //unregisterForContextMenu(l); //Then unregistering here...
  }
  
  @Override  
  public void onCreateContextMenu(ContextMenu menu, View v,ContextMenuInfo menuInfo) { 
      super.onCreateContextMenu(menu, v, menuInfo);  
  
      //menuInfo will be null here.
  
      menu.setHeaderTitle("Context Menu");
      menu.add(0, v.getId(), 0, "One");  
      menu.add(0, v.getId(), 0, "Two");
      menu.add(0, v.getId(), 0, "Three");
  }
  
  @Override  
  public boolean onContextItemSelected(MenuItem item) {
      AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
      if(info == null) {
          Log.e("","NULL context menu intem info...");
          return false;
      }
  }
  
  public void UpdateTable() {
      cursor = DatabaseHelper_Main.GetCursor(my_id);
      cursorAdapter = new SimpleCursorAdapter(this, R.layout.my_listview_entry, 
              cursor, fields, fieldResources, 0);
      setListAdapter(cursorAdapter);
  }
  
  ...
  </code></pre>