Android Question Correct Intent to Share URL

andrewj

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

Erel

Administrator
Staff member
Licensed 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.basic4ppc.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
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
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