你能告诉我DialogFragment
屏幕旋转后如何显示吗?我参加BroadcastReceiver
了父活动,当接收者收到我调用的函数showDialog()
时GetHelpFragment
。直到屏幕旋转一切正常,但旋转后我得到RuntimeException
了这个:
public void showDialog() {
new AutomaticDialogFragment().show(getFragmentManager(), "AutomaticDialogFragment");
}
这就是我在Activity
:
@Override
protected void onCreate(Bundle savedInstanceState) {
mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action.equals(GetHelpFragment.INTENT_SHOW_DIALOG)) {
getHelpFragment.showDialog();
}
}
};
IntentFilter ifilt = new IntentFilter(GetHelpFragment.INTENT_SHOW_DIALOG);
registerReceiver(mReceiver, ifilt);
}
@Override
public void onDestroy() {
super.onDestroy();
unregisterReceiver(mReceiver);
}
为什么它可以像当前那样工作?我该如何解决?
感谢帮助。