如何向 Linkify 创建的意图添加额外内容?

发布于 2024-10-05 05:45:14 字数 330 浏览 0 评论 0原文

我创建了一个内容提供程序(一个单词及其定义数据库)。我还有一个将显示单词及其定义的活动,该活动需要两件事:自定义 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

左耳近心 2024-10-12 05:45:14

查看源代码后,我找到了创建 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文