Reputation: 3081
I am saving a key value pair before displaying the warning dialog. However the onCreateDialog()
for the dialog is called with a null bundle. Is there something extra I need to do to pass the bundle to the dialog?
MyDialogFragment testFrag= new MyDialogFragment();
Bundle args = new Bundle();
args.putString("car-type", "Audi");
testFrag.setArguments(args);
testFrag.show(getFragmentManager(), "info");
Upvotes: 2
Views: 1838
Reputation: 39397
The setArguments
bundle is retrieved using getArguments
.
The savedInstanceState
bundle that is a parameter of the onCreateDialog
method is the bundle populated in onSaveInstanceState
.
These 2 are completely unrelated.
Upvotes: 3
Reputation: 3539
You can retrieve the arguments via DialogFragment.getArguments()
.
The savedInstanceState
is only used when a configuration change occurred. It is being filled in onSaveInstanceState(Bundle outState)
and later passed to the new DialogFragment
in onCreate()
and onCreateView()
. The first time a Fragment or Activity gets created it is null
.
Upvotes: 9