android linkify 意图

发布于 2024-09-09 04:27:31 字数 510 浏览 2 评论 0原文

我有一个 ListView,它使用 Linkify 创建指向我的应用程序中另一个活动的链接。 url 看起来像 content://com.myapp/activitiy/view?param=blah

这每次都工作正常。

然而,在另一种观点中,我试图调用一些这样的代码:

   Intent i = new Intent("content://com.myapp/activity/view?param=blah");
   i.setAction(Intent.ACTION_VIEW);
   startActivity(i); 

但由于某种原因,这似乎不起作用。它不会触发我的活动(事实上,如果我不包含 setAction() 调用,它就会爆炸。我应该如何创建 Intent,使其与 Linkify 的行为方式相同...?

现在我意识到我可以设置额外的内容,然后在活动中处理它,但这似乎是重复的工作,所以我会花时间来做这件事,并发布这个问题,非常感谢:)。

I have a ListView that uses Linkify to create a link to another activity in my app. the url looks something like content://com.myapp/activitiy/view?param=blah

this works fine every time.

however, in another view, I'm trying to call some code like this:

   Intent i = new Intent("content://com.myapp/activity/view?param=blah");
   i.setAction(Intent.ACTION_VIEW);
   startActivity(i); 

but for some reason this doesn't seem to work. It doesn't trigger my activity (and in fact it blows up if i dont include the setAction() call. How am I supposed to create the Intent such that it acts the same way that Linkify does...?

Now i realize i can setup the extras and then handle it in the activity, but that just seems like duplicated effort. So instead i'll spend the time it would have taken to do that, and post this question. SO any help much appreciated. :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

吲‖鸣 2024-09-16 04:27:31

啊。刚刚想通了:

String uri = "content://...";
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
startActivity(i);

ah. just figured it out:

String uri = "content://...";
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
startActivity(i);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文