Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What use instead of deprecated android.preference library on android 10+?

I start new tv app and now I need to develop dynamic preferences for set quality of stream, language of stream etc. So I was planning to use android.preference library and dynamically generate perfs base on stream data. But on https://developer.android.com/guide/topics/ui/settings.html is

Note: This guide explains how to use the AndroidX Preference library. Starting with Android 10, the platform android.preference library is deprecated.

But there is no redirection to replacement. So what to use in place of android.preference library?

Also on that guide is also note:

Note: This guide assumes you are using androidx.preference:preference:1.1.0-alpha04 or higher. Some features might be unavailable on older versions of the library.

so androidx.preference:preference will be deprecated.

like image 496
LunaVulpo Avatar asked Jan 25 '23 20:01

LunaVulpo


1 Answers

the platform android.preference library is deprecated. But there is no redirection to replacement.

You can check in Android 10 documentation:
The android.preference library is deprecated as of Android 10. Developers should instead use the AndroidX preference library, part of Android Jetpack.

The replacement is the androidx-preference library.
Just use:

dependencies {
    def preference_version = "1.1.0"

    // Java
    implementation "androidx.preference:preference:$preference_version"
    // Kotlin
    implementation "androidx.preference:preference-ktx:$preference_version"
}

More info about the release notes.

Also:

Note: This guide assumes you are using androidx.preference:preference:1.1.0-alpha04 or higher. Some features might be unavailable on older versions of the library.

It means that while a release is in alpha, APIs may be added, removed, or changed.

like image 169
Gabriele Mariotti Avatar answered Feb 12 '23 00:02

Gabriele Mariotti