What is the appropriate replacement of deprecated getSupportLoaderManager()?

前端 未结 6 2197
你的背包
你的背包 2020-12-08 07:46

I came to know that getSupportLoaderManager is deprecated. But I want to call:

getSupportLoaderManager().initLoader(0, null, mRecipeLoaderManager);
         


        
6条回答
  •  北荒
    北荒 (楼主)
    2020-12-08 08:29

    The reason why this method is deprecated is because Loaders have been unbundled from their historical Fragment and FragmentActivity implementations in order to live in their own library that will soon be an optional dependency, and their implementation has been rewritten on top of architecture components.

    The unbundled way of retrieving a LoaderManager instance is to use the static factory method:

    LoaderManager.getInstance(T)

    where T is an instance of both LifecycleOwner and ViewModelStoreOwner (the main implementations being FragmentActivity and Fragment).

提交回复
热议问题