2017-01-19 4 views
0

Ce que je veux6 Android bandes lien de texte avec la méthode Html.fromHtml()

gmail Ouvrir avec un certain texte qui contient des ancres.

Ce que j'attends

J'attend à ce que le texte est présenté dans Gmail avec un point d'ancrage à un site Web.

Problème

Sur Android 4.1.2 (et peut-être d'autres appareils Android al 4), il fonctionne très bien, mais sur Android 6, il ne fonctionne pas. Il montre le texte de l'ancre mais pas l'ancre elle-même.

Comme "un site Web" en texte brut au lieu d'un lien.

code

dans strings.xml:

<string name="bring_a_friend_mail"><a href="http://google.nl">a website</a></string> 

aussi essayé avec:

<string name="bring_a_friend_mail"> 
     <![CDATA[ 
      <a href="http://google.nl">a website</a> 
     ]]> 
    </string> 

et dans le code java:

shareBodyMail = getString(R.string.bring_a_friend_mail); 

sharingIntent = new Intent(Intent.ACTION_SEND); 
sharingIntent.setType("text/html"); 
sharingIntent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(shareBodyMail)); 

Solution

Quelqu'un peut-il m'aider à donner des directions?

Répondre

0

Essayez d'utiliser SpannableString

SpannableString s =new SpannableString(Html.fromHtml(shareBodyMail)); 
     Linkify.addLinks(s, Linkify.WEB_URLS); 

sharingIntent.putExtra(Intent.EXTRA_TEXT, s); 
+0

Je l'ai essayé, mais cela ne fonctionne pas :(toujours obtenir simplement le texte sans lien – Extranion

+0

essayez de supprimer Html.fromFtml – Rasel

+0

Merci de nous aider, mais cela ne fonctionne pas non plus. Seulement obtenir "un site Web" sans lien. got SpannableString s = new SpannableString (shareBodyMail); – Extranion