The CommonsBlog


At Last... HtmlCompat

In the 28.0.0 edition of the support libraries ActiveX AndroidX Jetpack(?), we will get an HtmlCompat, offering an API compatible with the current implementation of Html. This will be very useful for getting consistent results both pre- and post-API Level 24, when the API was revamped, which deprecated methods like the one-parameter version of Html.fromHtml().

Such a class had been suggested two years ago, and it’s good to see that it was added.

OTOH, HtmlCompat suffers from the same documentation limitation as does Html: no specification for what subset of HTML is supported. API Level 24 expanded the support from the roster that I wrote up 8 years ago, but there is no official list of what is and is not supported. As a result, handing arbitrary HTML to HtmlCompat is still risky, in that you might wind up with a mix of actual formatting and unprocessed HTML tags.

But, this is still a step in the right direction, and I am grateful for it.


Need Android app development training for your team? Mark Murphy has trained hundreds! Learn more!