The Android Developer guide has a decent section on the use of Fragments. One way to use Fragments is without a UI. There are a few references to using this as a means of background processing, but what advantages do Fragments bring to this area? Where would I choose to use a Fragment over Threads, AsyncTasks, Handlers, etc. for background processing?
Share
A
Fragmentinstance can persist through device configuration changes (like screen rotation). Because anActivitywill be destroyed and recreated when a configuration change happens, it’s difficult to design one that will keep track of a thread orAsyncTask. On the other hand, the system takes care of reattaching a persistedFragmentto the properActivityat the other end (so to speak) of the configuration change. You would still be using a thread orAsyncTask, only now theFragmentis holding it instead.There may be other uses for it, but there’s the one I can think of.