Bug 27087 - Fragment in a Fragment after rotate do not add into the page.
Summary: Fragment in a Fragment after rotate do not add into the page.
Status: RESOLVED INVALID
Alias: None
Product: Components
Classification: Xamarin
Component: Xamarin Components ()
Version: Production (addons.xamarin.com)
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bill Holmes
URL:
Depends on:
Blocks:
 
Reported: 2015-02-16 04:20 UTC by cheansiong
Modified: 2015-03-05 13:20 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED INVALID

Description cheansiong 2015-02-16 04:20:31 UTC
Precondition
1. All fragment has RetainInstance = true
2. Use Component Android Support Library v4
3. Layout of Fragment has ViewPager, each page has a fragment

Recently, our project perform the upgrade to target Lollipop. However, the part that has the above conditions do not work after rotate. I created a sample project that could simulate this issue.
Steps to reproduce:
1. Run the application.
2. The application allows you to slide left and right. Sliding from left and right will shows another fragment with 2 different values and color.
3. Rotate the device at any time, the fragment within the pager do not appears.
I noticed the following is printed with bold.

[] PageFragment OnSaveInstanceState: pageradaptertest.SlidingMainActivity@413bc810-PageFragment{413ffcb8 #1 id=0x7f050009} 1 start
[] PageFragment OnSaveInstanceState: pageradaptertest.SlidingMainActivity@413bc810-PageFragment{413ffcb8 #1 id=0x7f050009} 1 end
** [PhoneWindow] Previously focused view reported id 2131034131 during save, but can't be found during restore.**
[] Content fragment: MainFragment{413ca730 #0 id=0x7f050005} start
[] Content fragment: MainFragment{413ca730 #0 id=0x7f0500````05} end

This is working earlier in the previous version before the new component Android Support Library v4 is added. The reason it is added is a lot of warning is shown after the build, and suggested us to update it.

A description with sample project to reproduce is also available here: http://forums.xamarin.com/discussion/32971/fragment-in-a-fragment-after-rotate-do-not-add-into-the-page
Comment 1 Jon Douglas [MSFT] 2015-03-04 14:10:48 UTC
As an additional note, the differences between the Android Support v4 versions are the following:

Old - Mono.Android.Support.v4

    <Reference Include="Mono.Android" />
    <Reference Include="Mono.Android.Support.v4" />

New - Xamarin.Android.Support.v4 - 21.0.3

    <Reference Include="Mono.Android" />
    <Reference Include="Xamarin.Android.Support.v4">

Additionally I can confirm that the RetainInstance=true on the OldTest project does not stand in the new support library when using Fragments within a FragmentStatePagerAdapter, it seems may have Google changed something?
Comment 2 Jon Douglas [MSFT] 2015-03-05 13:20:31 UTC
Customer pointed out that 

http://developer.android.com/reference/android/app/Fragment.html#setRetainInstance(boolean)

Based on the latest documentation for Retain Instance in below, *...can only be used with fragments not in the back stack...*, I guess the meaning is that it is not usable in this situation.

Thus marking this bug Invalid.