2

I have a DialogFragment subclass that I'm using, and I'm getting some crashes when it's dismissed. It doesn't happen every time, and I can't seem to find a pattern to it. The crash is happening inside the overridden onDismiss() function.

java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter dialog
at com.foo.MyDialogFragment.onDismiss(Unknown Source:2)

This is the DialogInterface parameter, and it is happening before any of my code runs, so I cannot do anything to prevent it. I cannot make the parameter dialog nullable, as that breaks the contract with DialogFragment and it won't compile.

Any idea what is causing this, and more importantly, what can I do? It seems like this should not ever be happening, but here I am.

Santanu Sur
  • 10,997
  • 7
  • 33
  • 52
Mark Herscher
  • 1,761
  • 2
  • 19
  • 32
  • @MartinZeitler no, it's not a duplicate of that. At all. – Mark Herscher Jan 20 '20 at 18:28
  • It's indeed an `IllegalArgumentException` ...but there nevertheless are no arguments (the code), so there is nothing to argue about. Please add the code which produces the issue and we might be able to talk... because by providing the exception without the code, you also supply illegal (or insufficient) arguments. – Martin Zeitler Jan 20 '20 at 20:02

1 Answers1

1

So you subclassed DialogFragment?

Then you should just be able to override onDismiss and for example only call super.onDismiss() when the dialog isn't null

You can also override onDismiss and Log to see when exactly it is called

This might also work:

@Override
public void dismiss()
{
    if (getFragmentManager() != null) super.dismiss();
}

Source

Merthan Erdem
  • 5,598
  • 2
  • 22
  • 29