Override the general paste context menu in Android

2019-04-16 01:02发布

问题:

I think that this is not possible but I think it is better to ask someone who knows the answer for sure.

Is it possible to create an android application that affect the context menu in all applications so that when the user long press an edit text view, not only the paste option will be visible but also my customized paste function?

What I want to do is to make it easy for the user to import texts from my application without leaving the application they are working in. One thing I have thought off is to create a service that listen for pressing volume up and down at the same time and copy my text string into the clipboard. The user must then also use the ordinary paste function.

回答1:

No, you cannot. The context menu is defined in each app, and you cannot (and should not) change the behavior of other applications from another application.

Though there may be valid use-cases for such a feature, it is a bad idea in general.