not able to call context menu
<p>following is my code.What i want is when a string is selected and i press view definition it returns me the 'selected string'.It is running fine in first run but when i long press again it shows no context menu.</p>

<pre><code>package com.select;

import android.app.Activity;
import android.os.Bundle;
import android.text.ClipboardManager;
import android.text.Editable;
import android.text.GetChars;
import android.view.ContextMenu;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnLongClickListener;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.EditText;
import android.widget.Toast;

public class Select extends Activity
{
    EditText text;
    private static final String TAG = Select.class.getName();

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        text = (EditText) this.findViewById(R.id.EditText01);
        this.registerForContextMenu(text);
    }

    @Override
    public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo)
    {
        super.onCreateContextMenu(menu, view, menuInfo);
        // Log.v(TAG, "Creating context menu for view="+view);
        // Clear current contents
        // menu.clearHeader();
        // menu.clear();
        // menu.setHeaderTitle("MENU");
        int len = text.getSelectionEnd() - text.getSelectionStart();
        if(len&gt;0)
        menu.add(Menu.NONE, Menu.FIRST, Menu.NONE, "view definition");




    }

    @Override
    public boolean onContextItemSelected(MenuItem item)
    {
        AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
          if (item.getTitle() == "view definition") {

              Toast.makeText(Select.this, "copy selected", Toast.LENGTH_SHORT).show();

          }

        switch (item.getItemId())
        {
        case Menu.FIRST:

            text.setSelection(text.getSelectionStart(), text.getSelectionEnd());
            System.out.println("&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;" + text.getSelectionStart());
            System.out.println("!!!!!!!!!!" + text.getSelectionEnd());
            int len = text.getSelectionEnd() - text.getSelectionStart();
            if (len == 0)
            {
                Toast.makeText(Select.this, "Select a word first", Toast.LENGTH_LONG).show();
            }
            else
            {
                char[] a = new char[len];
                String s = null;
                for (int j = text.getSelectionStart(); j &lt; text.getSelectionEnd(); j++)
                {
                    a[j] = text.getText().toString().charAt(j);
                    s = new String(a);
                }
                System.out.println("SELECTED STRING " + s);
                 text.setSelection(0, 0);
                return true;
            }
        default:
            return super.onContextItemSelected(item);

        }
    }

}
</code></pre>
