Android share Intent with clickable link -
i have looked around web have yet find solution fits specific need. looking way share information share intent provides clickable link, like:
check out news article
via jimmy's news app
i have set share intent in android app looks this:
intent shareintent = new intent(); shareintent.setaction(intent.action_send); shareintent.putextra(intent.extra_subject, "subject text"); shareintent.putextra(intent.extra_text, "check out news article" + "\n\n" + getresources().gettext(r.string.shared_via)); shareintent.settype("text/plain"); startactivity(intent.createchooser(shareintent, "share article with..."));
my string resource looks this:
<string name="shared_via">via <a ref="http://google.com">jimmy's news app</a></string>
the sharing functions should when shared in email, twitter, etc. link ignored , tweet shows plain text this:
i tried playing around mime type, still no cigar. there anyway "jimmy's news app" clickable when shared? more greatful , , or tips.
thanks in advance!
first, wouldn't have expected project build, string resources not support arbitrary html tags. documented ones <b>
, <i>
, , <u>
.
second, if support arbitrary html tags, converting spanned
(gettext()
) plain string, remove formatting.
to overcome both problems, either move string java (after all, it's not have i18n going, hardcoded english elsewhere in code snippet), or wrap string content in cdata
(while fixing broken html, use href
<a>
attribute):
<string name="shared_via"><![cdata[via <a href="http://google.com">jimmy's news app</a>]]></string>
at point, if @ concatenated string, should quasi-html source:
check out news article via <a href="http://google.com">jimmy's news app</a>
next, while sending on html, declaring plain text. many apps therefore treat plain text, , may ignoring tag showing raw html. welcome try text/html
mime type , see if better results.
finally, there no requirement app honor links. action_send
request, not command. there no rules how third-party apps use html send over, , going varying results varying apps.
Comments
Post a Comment