getLoaderManager in Fragments is deprecated
Asked Answered
S

3

12

After update I found that getLoaderManager is deprecated but I can't find that should I use instead of.
How to get LoaderManager? Or what should I use instead of Loaders?

Semipalmate answered 1/9, 2018 at 12:53 Comment(2)
developer.android.com/guide/components/loadersCharlie
@AngusTay, thank you, I understood the problem in English version. Just Google decided that it's not an important information to show in Russian site version that Loaders are deprecated.Semipalmate
S
17

Loaders have been deprecated as of Android P (API 28). The recommended option for dealing with loading data while handling the Activity and Fragment lifecycles is to use a combination of ViewModels and LiveData.ViewModels survive configuration changes like Loaders but with less boilerplate. LiveData provides a lifecycle-aware way of loading data that you can reuse in multiple ViewModels.

Sillsby answered 31/10, 2018 at 4:10 Comment(0)
E
6

getLoaderManager has been deprecated, use LoaderManager getInstance instead:

LoaderManager.getInstance(this).initLoader(0, null, this);
Electroacoustics answered 10/7, 2020 at 15:12 Comment(0)
B
0

The deprecated getLoaderManager has been replaced with getSupportLoaderManager. Try:

getSupportLoaderManager().initLoader(LOADER_NOTES, null, this); 

Works for me in API 28.

Brachiate answered 17/4, 2020 at 16:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.