当您长按 Android 中的某个内容时,会出现一个上下文菜单。我想为所有人添加一些内容到这个上下文菜单中TextViews
在系统中。
例如,系统通过复制和粘贴来执行此操作。我想添加我自己的,并让它出现在每个应用程序中。
在您的文件 android-manifest.xml 中添加意图过滤器:
<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>
在方法 onCreate() 中通过应用程序活动中的用户文本突出显示:
@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
}
有关更多信息,请参阅文章medium.
感谢用户:永刃
他的回答是ru.stackoverflow.com
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)