While passing Android DialogFragment arguments, onCreateDialog bundle agument is unexpectedly null

冷暖自知 提交于 2019-12-03 14:36:35

you have to use getArguments to retrieve the Bundle you set with setArguments

Instead of

if(savedInstanceState != null) {
     dialogMessage = savedInstanceState.getString(DIALOG_MESSAGE);
}

you should have something like:

Bundle bundle = getArguments();
if (bundle != null) {
    dialogMessage = bundle.getString(DIALOG_MESSAGE);
}

I had the same problem, you have to use getArguments, as Blackbelt said.

The savedInstanceState will be available when onSaveInstanceState (documentation) is called and some data is filled in outState, to be retrieved latter.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!