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?
Try using SpannableString
SpannableString s =new SpannableString(Html.fromHtml(shareBodyMail));
Linkify.addLinks(s, Linkify.WEB_URLS);
sharingIntent.putExtra(Intent.EXTRA_TEXT, s);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.