How to add item into popup copy/paste menu on a an

2019-04-08 07:09发布

please look this screenshot. In normal case, when text be selected, a popup menu opened, but only have cut/paste item. I want to know, how to add item just like this "web search / share" into this popup menu?

What's this popup menu? I had tried to override Activity Context or Option Menu, but it' not. I had also tried to extends TextView and override it's Context menu, but no use, only show a normal dialog context menu, and this cut/paste menu disappered.

enter image description here

1条回答
Rolldiameter
2楼-- · 2019-04-08 07:50

Before the api23,I have no ideal too. But now we can get it use ACTION_PROCESS_TEXT with api23. Include this code in the AndroidManifest.xml file.

 <activity
        android:name=".YourActivity">
        <intent-filter>
            <action android:name="android.intent.action.PROCESS_TEXT" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="text/plain" />
        </intent-filter>
</activity>

Install your app, then you can find your app name in the text selection menu.

Sample

Read the documentation for more information.

查看更多
登录 后发表回答