addLinks用于打开活动或使用带语法的span

时间:2017-04-05 12:17:29

标签: android android-studio android-intent

我试图制作一个标签系统。 所以我试过了:

holder.textViewPublisher.setText(post.getPublisher());
Pattern tagMatcher = Pattern.compile("[#]+[A-Za-z0-9-_]+\\b");
String url = "https://www..com";
Linkify.addLinks(holder.textViewPublisher, tagMatcher, url);

这有效但只能打开一个网址。我想打开一个将hashtag值发送给它的活动。

如何打开活动而不是链接? 我需要使用span吗?任何例子?

1 个答案:

答案 0 :(得分:1)

您可以将deeplinks与params一起使用。

因此,您将使用看起来像

的相同链接
myapp://myhost?activity=activity_name

然后您只需将参数活动捕获为String,然后运行您需要的活动。