如何向 Linkify 创建的意图添加额外内容?
我创建了一个内容提供程序(一个单词及其定义数据库)。我还有一个将显示单词及其定义的活动,该活动需要两件事:自定义 Parcelable extra,当然还有单词。
目标是在我的应用程序中的大文本中,Linkify 将匹配一些单词,当用户单击它时,它将显示一个包含该单词及其定义的活动。这些单词存储在数据库中,因此是内容提供者。该活动需要显示单词以及一个附加的 Parcelable。但是 Linkify 不提供对 Intent 的访问。目前意图仅包含要定义的单词。
我应该做什么才能将自定义 Parcelable 添加到由 Linkify.addLinks
隐式创建的 Intent 中?
I have created a content provider (a word and its definition database). I also have an activity that will display a word and its definition, this activity requires two things: a custom Parcelable extra, and of course the word.
The goal is that in big texts in my app, Linkify will match some words, and when the user clicks on it it will display an activity with the word and its definition. The words are stored in a database, hence the content provider. The activity requires the word to be displayed, and an additional Parcelable. However Linkify does not provide access to the Intent. Currently the intent only contains the word to be defined.
What whould I do to be able to add the custom Parcelable to the Intent created implicitly by Linkify.addLinks
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看源代码后,我找到了创建 Intent 的位置:
https:// android.googlesource.com/platform/frameworks/base/+/master/core/java/android/text/style/URLSpan.java
感谢开源,我创建了自己的 Linkify 类(从 Linkify 复制)还使用它自己的 URLSpan 副本,其中考虑了我想要使用的 Parcelable。
After looking in the source I have located where the Intent is created:
https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/text/style/URLSpan.java
Thanks to open source, I created my own Linkify class (copied from Linkify) which uses also its own URLSpan copy, that takes into account the Parcelable I wanted to use.