androidhtmlentity

Converting html entities to characters in Android


I am parsing JSON data and using it in Android textview.

And I am getting &lt; instead of <, etc.

I tried with

Html.fromHtml("ur text here");

but this is deprecated and Android studio is not allowing me to use it.

As I saw in google documentation i need to use 2 parameters, from which other is some int Flag, and I don't know how to use it.


Solution

  • Just use

    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
        Html.fromHtml("ur text here",Html.FROM_HTML_MODE_LEGACY);
    } else {
        Html.fromHtml("ur text here");
    }