6

When I enter some text and press and hold on it then context menu is presented with items like cut,copy,select text and so on.

Is there any way to add my own custom item to this context menu ? I do not how this things works but I guess that should be possible to register something in the manifest just like registering activities and broadcasts . . .

Thanks,

Any ideas are wellcomed

enter image description here

Till Helge
  • 9,253
  • 2
  • 40
  • 56
Lukap
  • 31,523
  • 64
  • 157
  • 244
  • 3
    You can use *intent filters* to make your application listen for certain events and present itself as viable option to handle it. For example, you can present your application as callable in case the user clicks a bus stop on a Google map. Same should be possible for the context menu you presented. – Till Helge Nov 01 '11 at 13:44
  • can you provide some source code ?, or give me some links ?, I have worked with intent-filter but I do not have idea what to register and how to make so menu item to be shown in android system menus... – Lukap Nov 01 '11 at 13:53

2 Answers2

3

Is there any way to add my own custom item to this context menu ?

Only for widgets in your own activities, not for the system as a whole.

Also, EditText is problematic even for your own activities, as some device manufacturers are bypassing the normal context menu system, so you can't add to them.

That being said, for your own activities, just follow the instructions to create a context menu for the widgets of interest.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
1

Have you tried putting an onLongClickListener on your EditText? This won't let you add to the current list, but you can make your own dialog show up and then add all the options above, or some of them, or none of them and your own.

I'm not sure if exactly what you're asking for is possible, and if it is my way is a little bit more work, but you'll have full control.

NotACleverMan
  • 12,107
  • 12
  • 47
  • 67
  • 1
    sorry this is not what I asked, I do not want to add item to my own activity I want to add an menu list item to the menus that are created from android. I want to register my app as handler for some special kinds of MIME types... – Lukap Nov 01 '11 at 13:51
  • Oh, you mean for the entire android system, and not just over-write something in your own app. I'm sorry, I completely misread that. I have no idea how to approach something like that. Please just ignore my answer :) Good Luck – NotACleverMan Nov 01 '11 at 13:59
  • no problem, maybe I didn't describe precisely what I want. I do not know even is this possible at all :-) . . . – Lukap Nov 01 '11 at 14:29