I am creating DialogFragment and when I want to override onCreateDialog
I receive the following warning:
not annotated method overrides method annotated with @NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
return super.onCreateDialog(savedInstanceState);
}
If I want to place that annotation to my method, Android Studio can't find that annotation.
Why is this happening? Thanks for your help.
Because you override a method which is defined with a @NonNull annotation (meaning the method must not return null), and you are not using the same annotation in your overridden implementation, so that makes it a mismatch.
Please search for your question before submitting, this is asked many times.
Meaning of Android Studio error: Not annotated parameter overrides @NonNull parameter
(Edit: Fixed meaning of @NonNull annotation, thanks ci_)
Looking at definition of the onCreateDialog
method in DialogFragment
, you will see:
@NonNull
public Dialog onCreateDialog(Bundle savedInstanceState)
So your code should include the same @NonNull
annotation like this:
@Override
@NonNull
public Dialog onCreateDialog(Bundle savedInstanceState) {
return super.onCreateDialog(savedInstanceState);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With