is empty constructor really required?
是.
Why does it work when orientation does not change?
因为Android不会尝试重新创建您的片段.
Why does it fail when orientation is changed?
因为Android正在重新创建你的片段.
当配置发生更改(例如,方向更改)时,默认情况下,Android会破坏并重新创建您的活动,并且还会破坏并重新创建该活动中的片段. “重新创建片段”部分是您需要片段上的零参数公共构造函数的原因.它也用于其他情况,例如FragmentStatePagerAdapter.
All subclasses of Fragment must include a public empty constructor. The framework will often re-instantiate a fragment class when needed,in particular during state restore,and needs to be able to find this constructor to instantiate it. If the empty constructor is not available,a runtime exception will occur in some cases during state restore.