I updated to the SDK Version 24 and now Html.fromHtml()
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 WebView
for this purpose.
Either:
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.
Just use
if (Build.VERSION.SDK_INT >= 24) { Html.fromHtml(String, int) // for 24 api and more } else { Html.fromHtml(String) // or for older api }
to use Html.fromHtml(String, int) for 24 api follow documentation:
https://developer.android.com/reference/android/text/Html.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With