2

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");
Willi Mentzel
  • 27,862
  • 20
  • 113
  • 121
user2399453
  • 2,930
  • 5
  • 33
  • 60

2 Answers2

9

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.

Maik
  • 3,419
  • 1
  • 23
  • 34
3

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.

njzk2
  • 38,969
  • 7
  • 69
  • 107