开发者

android linkify intent

开发者 https://www.devze.com 2023-01-07 14:00 出处:网络
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

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 th开发者_运维技巧is 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. :)


ah. just figured it out:

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

精彩评论

暂无评论...
验证码 换一张
取 消