Android Question Correct Intent to Share URL

andrewj

Active Member
Licensed User
Longtime User
Hi,
Does anyone know the correct form of intent to use to share a URL rather than a file?
Thanks
Andrew
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Sharing a url is similar to sharing text:
B4X:
Dim i As Intent
i.Initialize(i.ACTION_SEND, "")
i.SetType("text/plain")
i.PutExtra("android.intent.extra.TEXT", "http://www.b4x.com")
i.PutExtra("android.intent.extra.SUBJECT", "This is the subject")
StartActivity(i)

upload_2014-3-9_10-6-47.png
 
Upvote 0

andrewj

Active Member
Licensed User
Longtime User
Thanks Erel, that works well.
Oddly though, the list includes non-browser apps which can consume a URL, but not the other browsers themselves. Does this require a slightly different intent, for an "Open in other browser" option?

Andrew
 
Upvote 0

andrewj

Active Member
Licensed User
Longtime User
Hi Erel,
I tried changing ACTION_SEND to ACTION_VIEW, but it doesn't work, I get a very odd selection of target apps, no browsers. Does the type need to change as well?

PS - V3.5 seems to be working well.
Thanks
Andrew
 
Upvote 0
Top