Ensure Fragment is Added before attempting to save state

When a FragmentStatePagerAdapter is set to a ViewPager in onCreate
the Fragments are populated, and it is assumed that they will be
added to the FragmentManager for saving state later. This is not
guaranteed and will result in an IllegalStateException if they are
not added, such as if a new Activity is started in onCreate.

This change checks Fragment.isAdded() before proceeding to save
state.

Issue: https://code.google.com/p/android/issues/detail?id=77285

Change-Id: I9197cb319a2b1bf070ab1fd8a7abbf9ee01de543
Signed-off-by: Bryan Emmanuel <piusvelte@gmail.com>
Merge "Ensure Fragment is Added before attempting to save state"