After some testing and viewing FragmentManager.moveToState, I believe that when the Fragment processed by the FragmentPagerAdapter , it is inevitable that a Fragment , which was previously merged into savedState (as part of the process of stopping the application before you kill the process from the DDMS tab in eclipse), first must be "created" (in the terminology of the FragmentManager ) before it can be destroyed,
This may be an unintended consequence of the process of restoring fragments from a saved state. When FragmentActivity onCreate and finish() called, it is assumed that FragmentActivity ceases to be configured and exits. The visual experience is that this happens, but it looks like the FragmentManager taking it upon itself to continue the life cycle for the pre-existing Fragment s, albiet with small reductions. This process apparently executes lifecycle methods before onActivityCreated , and then executes onDestroy and onDetach , passing them between them.
The best way to handle this, apparently, is to solve the secondary problems (in this case, your NPE) caused by this launch. It seems that there is an opportunity to optimize this from the Fragment life cycle, but with the r12 support library, the situation seems to be a consequence of the design.
Nick campion
source share