'PreferenceFragment' is deprecated. Deprecated in Java
Some digging through the Android documentation resulted in a solution; the android.preference.PreferenceFragment class is being deprecated and can be replaced with the new Jetpack androidx preference classes. So I needed to do the following:
- Add a new dependency to the new Androidx preference library in the app's build.gradle file
implementation "androidx.preference:preference:1.0.0"
- In the Kotlin source code, remove the following namespace import statement:
import android.preference.PreferenceFragment
- Insert the following namespace import statement:
import androidx.preference.PreferenceFragmentCompat
- Then override the abstract onCreatePreferences method.
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { // TODO("not implemented") //To change body of created functions use File | Settings | File Templates. }
No comments:
Post a Comment