Aawaz Gyawali Aawaz Gyawali - 7 months ago 114
Android Question

Html.fromHtml() is deprecated, what is the alternative?

I updated to the SDK Version 24 and now

is deprecated. And the Html class has a a new method with extra parameter named flag, but it's minimum API is 24.

Is there any alternative to this function to the lower API versions?. I don't want to use a
for this purpose.



  • Use Html.fromHtml(String) on all API levels, or,

  • Use Html.fromHtml(String) on API Level 23 and older devices, and Html.fromHtml(String, int) on API Level 24+ devices, using Build.VERSION.SDK_INT to find out the API level of the device that you are running on

In this case, "deprecated" is a hint to go look for the two-parameter method, but the one-parameter method still works and (in all likelihood) will do so for quite some time.