One of the challenges of developing Android applications is to ensure that our applications effectively handle the life cycle of the application's activities. During the lifetime of an application, a given activity may be created, destroyed, and recreated many times. A simple action, such as a user rotating a device from the portrait to landscape orientation or vice-versa, normally causes the visible activity to be completely destroyed and recreated using the appropriate resources for the new orientation. Applications that do not cooperate effectively with this natural life cycle often crash or behave in some other undesirable manner.
Each fragment instance exists within a single activity; therefore, this fragment must cooperate in some way with the activity life cycle. In fact, not only do fragments cooperate with the activity life cycle, but also they are intimately connected.
In the setup and display phases, as well as in the hide and teardown phases...