0

Planned to implement a global context menu for text(Editext, Textview).

Global Context Menu

A new option should be there to add the selected word to my wordcollector kind of application. How to add the above option to global context menu.

Satheesh
  • 646
  • 1
  • 10
  • 33

1 Answers1

0

you can change the application's context menu like this:

@Override
public void onCreateContextMenu(ContextMenu menu, View v,
    ContextMenuInfo menuInfo) {
  if (v.getId()==R.id.list) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo)menuInfo;
    menu.setHeaderTitle("EditText");
    String[] menuItems = //your menu item. you can add the "add word to dictionary" as an item here.
    for (int i = 0; i<menuItems.length; i++) {
      menu.add(Menu.NONE, i, i, menuItems[i]);
    }
  }
}

You cannot change the Global context menu. You cannot override or hook functionality globally at the system level without the particular activity implementing an intent or activity that you expose. Even in the case of publishing an intent it wouldn't matter unless the application running is a consumer... and all the base system applications and obviously all applications prior to yours would not be without updating the app to consume.

PrincessLeiha
  • 3,144
  • 4
  • 32
  • 53
  • Thanks for the snippet. But i need to implement a global context menu. It should work in all applications(Message, Browser) While selecting text. – Satheesh May 15 '12 at 11:14
  • I know where is the answer from http://stackoverflow.com/questions/559405/android-add-item-to-global-context-menu See the last comment for the first answer "It is possible, it's just not pretty :-\ – haseman Feb 20 '09 at 23:31" – Satheesh May 15 '12 at 11:29
  • ask user "haseman" in that link itself... links are not recommended as a part of the answer, so i copied the contents. You know it, then you better continue the conversation there... – PrincessLeiha May 15 '12 at 11:34
  • Meant in the way i saw the post already :P I just asked you to notice the comment. – Satheesh May 15 '12 at 11:40
  • that's what i am telling, comment on the comment, and ask him what he knows about it... :) – PrincessLeiha May 15 '12 at 11:51