Getting a clickable URL from strings.xml for a share Intent Android Studio -


i've been searching hours trying share intent hyperlink specific url. saw lot of answers textview none sharing intent , couldn't figure out how textview answers applied this.

basically want string

<string name="link"><a href="https://play.google.com/store/apps/details?blahblah">eatingout</a></string> 

to work with

    @override     protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_restaurant);     share = getstring(r.string.link); }      private void setshareintent() {      if (mshareactionprovider != null) {          intent shareintent = new intent(intent.action_send);         shareintent.settype("text/plain");         shareintent.putextra(intent.extra_subject, "share");         shareintent.putextra(intent.extra_text, "eating @ "+ title.gettext() + " #" + share );          mshareactionprovider.setshareintent(shareintent);     } } 

the problem when share it, there no hyperlink "share" part. have tried many different suggestions read here said textviews

edit: tried textutils.concat still no hyperlink , without "#"

        charsequence socialshare = textutils.concat("eating @ ", title.gettext(), " #", share);                     intent shareintent = new intent(intent.action_send);         shareintent.settype("text/plain");         shareintent.putextra(intent.extra_subject, "share");         shareintent.putextra(intent.extra_text, socialshare ); 

the problem when share it, there no hyperlink "share" part.

you have few problems here.

first, not aware <a> valid html-style tag can use in string resource.

second, getstring() remove html-style markup, if exists.

third, setting mime type of action_send intent text/plain, , html different mime type.


given that, need decide whether going share plain text url in text (relying upon "share" recipient identify url , make useful user, if applicable), or if going share html (and hope "share" recipient doesn't screw bad).

if going share plain text, change string resource to:

<string name="link">https://play.google.com/store/apps/details?blahblah</string> 

you want either rid of # in concatenated string, or add space after it, putting # right before url may confuse other apps, causing them not recognize url being url.

if going share html, need change settype() pass text/html, set extra_text either html-formatted string or spanned object (e.g., created via spannablestringbuilder).


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -