What is the use case for a Fragment with no UI?

A Fragment instance can persist through device configuration changes (like screen rotation). Because an Activity will be destroyed and recreated when a configuration change happens, it’s difficult to design one that will keep track of a thread or AsyncTask. On the other hand, the system takes care of reattaching a persisted Fragment to the proper Activity at the other end (so to speak) of the configuration change. You would still be using a thread or AsyncTask, only now the Fragment is holding it instead.

There may be other uses for it, but there’s the one I can think of.

Leave a Comment

tech