0

What I want

Open gmail with a certain text that contains anchors.

What I expect

I expected that text is shown in Gmail with a anchor to a website.

Problem

On Android 4.1.2 (and maybe al other android 4 devices) it works really well, but on Android 6 it doesn't work. It is showing the text of the anchor but not the anchor itself.

Like "a website" in plain text instead of a link.

Code

in strings.xml:

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

also tried with:

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

and in java code:

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

Can someone help me to give some directions?

Extranion
  • 588
  • 8
  • 25

1 Answers1

0

Try using SpannableString

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

sharingIntent.putExtra(Intent.EXTRA_TEXT, s);
Rasel
  • 5,488
  • 3
  • 30
  • 39