Android AsyncTaskLoader doesn't start loadInBackground?

后端 未结 6 1643
有刺的猬
有刺的猬 2021-01-30 10:23

I am trying to implement a loader example on Android but can\'t get it to start the loader. I am using the following code. It will hit the \"Create Loader\" but it will never re

6条回答
  •  太阳男子
    2021-01-30 10:43

    I had the same problem using the compatibility library. I solved it by calling forceLoad

    getLoaderManager().initLoader(0, null, this).forceLoad();
    

    Obviously the documentation on AsyncLoader is lacking and this problem also exists on HoneyComb. More information can be found here

    The official example of AsyncTaskLoader is also calling forceLoad() so its not a bug, but i still think that that behavior is not very intuitive.

提交回复
热议问题