Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use HtmlCompat?

I have the following code:

Html.fromHtml(getString(R.string.privacy_policy_text)

however, Html.fromHtml() is deprecated. I know I am supposed to use HtmlCompat as indicated here. However, I don't know what I have to include in my build.gradle file for that class to be available even after a lot of Googling.

I already have the following support libraries in my build.gradle:

implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:support-vector-drawable:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.android.support:recyclerview-v7:27.1.1'
like image 358
Roymunson Avatar asked Jul 08 '18 23:07

Roymunson


1 Answers

In the current edition of the Android JavaDocs, there are notes about which artifact supplies a particular class.

HtmlCompat JavaDocs

Here, we see "belongs to Maven artifact androidx.core:core:1.0.0-beta1`. That tells you a specific artifact and version to use, though the version you may need to synchronize with other artifacts that you are using.

This is an androidx artifact, as a part of the grand refactoring of the Support Library. This may cause problems with your project, which is using the classic Support Library artifacts. You may wish to hold off on using HtmlCompat until you can switch your whole project over to androidx artifacts.

like image 129
CommonsWare Avatar answered Nov 03 '22 23:11

CommonsWare