这样会出错,因为onSaveInstanceState方法是在该Activity即将被销毁前调用,来保存Activity数据的,如果在保存玩状态后再给它添加Fragment就会出错。解决办法就是把commit()方法替换成 commitAllowingStateLoss()就行了
```
CustomFragmentDialog voucherFragmentDialog = ustomFragmentDialog.newInstance(sourceType);
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.add(voucherFragmentDialog,VoucherFragmentDialog.class.getName());
fragmentTransaction.commitAllowingStateLoss();
```