最佳答案
这个概念被称为 ACTION_PROCESS_TEXT
并在 Android 6 中可用:
在您的 list 中定义一个 Intent 过滤器:
<activity android:name=".YourActivity"
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>
然后在您的 Activity 中处理 Intent :
Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.process_text_main);
CharSequence text = getIntent()
.getCharSequenceExtra(Intent.EXTRA_PROCESS_TEXT);
// process the text
boolean readonly = getIntent()
.getBooleanExtra(Intent.EXTRA_PROCESS_TEXT_READONLY, false);
}
您只能为每个 Activity 定义一个 Action。
关于Android Marshmallow 文本选择选项菜单操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34559992/