android linkify 意图
我有一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
啊。刚刚想通了:
ah. just figured it out: