Difference between initLoader and restartLoader in LoaderManager

后端 未结 6 620
春和景丽
春和景丽 2020-12-22 16:17

I\'m completely lost regarding the differences between the initLoader and the restartLoader functions of the LoaderManager:

6条回答
  •  时光取名叫无心
    2020-12-22 16:49

    If the loader already exists, restartLoader will stop/cancel/destroy the old one, while initLoader will just initialize it with the given callback. I cannot find out what the old callbacks do in these cases, but I guess they will just be abandoned.

    I scanned through http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.0.1_r1/android/app/LoaderManager.java but I cannot find out what the exact difference is, apart from that the methods do different things. So I would say, use initLoader the first time and restart for the following times, though I cannot say with certainty what each of them will do exactly.

提交回复
热议问题