Perhaps this question has already been asked, but I never found it. How to add an item to the "global" context menu. What is called in all applications when text is selected:
- oneSee this article here: medium.com/androiddevelopers/… - YungBlade 6:52 pm
- @YungBlade, please put as an answer to the question. - Valeriy
|
1 answer
Add the following intent-filter to your android-manifest.xml file:
<activity android:name=".ProcessTextActivity" android:label="@string/process_text_action_name"> <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> Get the text selected by the user in the activity of your application in the onCreate () method:
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.process_text_main); CharSequence text = getIntent() .getCharSequenceExtra(Intent.EXTRA_PROCESS_TEXT); // получение текста } More information in the article on medium .
|
