Is it possible to add something to the list of items that shows up when a user long presses on any Edit Text? (Cut, copy paste, select text, select all, input method) I want to add an option to this that will scan a QR code and paste the result into the Edit Text. I think this would not be very hard to get this behavior out of Edit Texts that I put into my own application, but I am wanting to add this option to any Edit Text inside any application on my phone. Is something like this possible, if so can anyone point me in the right direction?
Edit 150 bounty: I am looking to add an item to the EditText pop-up dialog when it is long pressed. I want am looking for a way to make this change system wide, not just within the context of 1 application.
There are 2 ways: 1st one described by Shahab. 2nd one is more simple. You need to just override standard method of your activity, like:
After that you'll have on long press popup context menu
Yes it is possible to add something to the list of items on LongClick of EditText.
To put you in right direction I am posting some code snippets.
In main.xml do something like
After that in your main Activity, do something like
Hope it helps
Thats not possible, as the context menu is populated by applications themselves and not by the system. You cannot force other apps to have a context item that they might not use in their lifetime. You can atleast have the feature in apps that are aware of your app.
Create an activity that populates and handles only your global menu items. Other apps can use the feature by extending your activity. But this too will create problems, as the other apps will have a hard dependency on your app. So if your app is not installed in that system then the other app won't work. Also there is no way to indicate of this dependency in the manifest file so that the dependent app is hidden in the market if your app is not already installed.
I'm sure this is not the answer you were looking for, but context menus are made so by design.