I am sending an sms from my java web application to Android and BB end user. This message has some HTML tags like anchor tag, bold tag etc. The same is getting displayed in the mobile end. Is it something I have to do encode or should it be done in mobile's end? I am new to this SMS implemenation. Can someone pls help me?

Thanks in advance.

有帮助吗?

解决方案

I guess you want to encode from your application and not in the mobile end ?

Then encode the html. I would suggest the best html encoder is StringEscapeUtils

StringEscapeUtils.escapeHtml(htmlString)

And if you want to do it from the mobile end then use Html.fromHtml (String source)

其他提示

An easy way to strip out tags (for display or to get the underlying non-HTML) is:

Spanned mySpannedString = Html.fromHtml(myString);

This creates a Spanned object (characters with mark-up) and you can extract the "string" with:

String myString = mySpannedString;
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top