I have a ViewGroup that programmatically instantiates and assigns an ID to a ViewPager. On rotation, the "Up" button and changing the screen orientation will recreate the Views -- but it doesn't remember the last page index of the ViewPager.
I've verified that OnSaveInstanceState() and OnRestoreInstanceState() are both being called, and both of them contain the correct page index information. But, the ViewPager gets reset to page index to 0 regardless. I notice that I get I message in the console
No package identifier when getting name for resource number [id that I programmatically defined]
As an experiment, I defined the ViewPager (along with the ID) in XML. It does correctly set the ViewPager to the last page index.
So, what I suspect is that the Android framework can't actually restore the last state correctly because the ID doesn't persist when the ViewGroup then ViewPager gets destroyed.
How can I get this to work? I'd like to contain all state relating things within this ViewGroup (eg avoid keeping track of the ViewPager position in Fragment). But, it doesn't seem like I can get this to work unless I can make the ID persist (if that's the root cause).