Android: LoaderCallbacks.OnLoadFinished called twice

前端 未结 10 2270
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-04 11:05

I noticed strange situation using Android Loaders and Fragments. When I invoke LoaderManager.initLoader() after orientation change onLoadFinished is not called (although doc

10条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-04 11:21

    You can put the initLoader() method inside your Fragment's onResume() callback; then the Loader's onLoadFinished() will not be called twice anymore.

        @Override
    public void onResume()
    {
        super.onResume();
        getLoaderManager().initLoader(0, null, this);
    }
    

提交回复
热议问题