This is an annotation, but the correct name is NonNull :
protected void onSaveInstanceState(@NonNull Bundle outState)
(And also)
import android.support.annotation.NonNull;
The goal is to allow the compiler to warn when certain assumptions are violated (for example, a method parameter that should always have a value, as in this particular case, although there are others). In the documentation Support for annotations :
The @NonNull can be used to indicate that this parameter cannot be null.
If the local variable is known as null (for example, since some earlier code checked to see if it was null), and you pass it as a parameter to a method where this parameter is marked as @NonNull, the IDE will warn you that you have a potential crash.
These are tools for static analysis. Runtime behavior does not change at all.
In this case, a special warning is that the original method that you override (in Activity ) has the @NonNull annotation in the outState parameter, but you did not include it in the override method. Just add it to fix the problem i.e.
@Override protected void onSaveInstanceState(@NonNull Bundle outState) { super.onSaveInstanceState(outState); }
matiash Jul 14 '14 at 3:18 2014-07-14 03:18
source share