开发者

Gmail subaddressing ('plus sign' addressing) in Android

开发者 https://www.devze.com 2023-01-11 00:22 出处:网络
This is a very simple issue. I\'m trying to put a link to an email address in a TextView, using Html.fromHtml.

This is a very simple issue. I'm trying to put a link to an email address in a TextView, using Html.fromHtml.

body.setText(Html.fromHtml("<a href=\"mailto:emailaddress+subaddress@gmail.com\">开发者_高级运维Contact</a>"));

When that link is clicked, a new email is addressed to "emailaddress subaddress@gmail.com". Notice that the plus symbol has disappeared. I've tried this:

body.setText(Html.fromHtml("<a href=\"mailto:emailaddress"+'+'+"subaddress@gmail.com\">Contact</a>"));

and

body.setText(Html.fromHtml("<a href=\"mailto:emailaddress&#43;subaddress@gmail.com\">Contact</a>"));

to the same result.

Anyone know how I can get the link to work correctly?


A + sign is one URL-encoded form of a space (the other is %20). To encode a literal + sign in a URL, you need to escape it in the same way - in this case as %2B

0

精彩评论

暂无评论...
验证码 换一张
取 消