java - Android loaders vs Handlers -


the loaders in asynchronously getting data data source. can achieve same effect using handlers, can kick off thread or execute executor , can fetch data in thread. once data fetched, can update ui using ui handler message mechanism. why go coding complex loaders when can achieve same using handlers.

loaders introduced make easier in implementing correct data loading on android platform. means:

  • doing heavy stuff on background thread
  • safely introducing loaded data in ui
  • caching of data, means improving speed
  • loaders can live outside activity lifecycle, if have config change data not destroyed
  • loaders reloaded once data store changes

using handlers,executors, or asynctasks not take account above points. have manage yourself, , work android developers put loaders implementation.

ie. using asynctask loading data requires watch out screen rotations, ie. must somehow retain reference asynctask might still in background once activity recreated due screen rotation.


Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -