ContextMenu throws a NullPointerException
<p>I'm trying to make a ContextMenu within my InputMethodService.</p>

<p>it gets initiates as</p>

<pre><code>private ContextMenu ContextMenuInfo = null;
</code></pre>

<p>then within OnLongClick it has</p>

<pre><code>ContextMenuInfo.setHeaderTitle("hello!");
ContextMenuInfo.add("aaa!");
ContextMenuInfo.add("bbb!");                
mInputView.createContextMenu(ContextMenuInfo);
</code></pre>

<p>but it throws a NullPointerException. any ideas what might be missing?</p>

<p>Thanks!</p>

<p>edit:</p>

<p>tried with</p>

<pre><code>public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {

menu.setHeaderTitle("Choose an option");
menu.add(0, v.getId(), 0, "Add to favorites");
menu.add(0, v.getId(), 0, "See details");

}
</code></pre>

<p>and within the longclick</p>

<pre><code>registerForContextMenu( v );
openContextMenu( v );
</code></pre>

<p>but they both give</p>

<p><strong>The method registerForContextMenu(View) is undefined for the type new View.OnLongClickListener(){}</strong></p>
