首页 > 代码库 > Android - Warning:Not annotated parameter overrides @NonNull parameter
Android - Warning:Not annotated parameter overrides @NonNull parameter
Warning:Not annotated parameter overrides @NonNull parameter
本文地址:http://blog.csdn.net/caroline_wendy
Warning:The @NonNull annotation can be used to indicate that a given parameter can not be null.
"@NonNull"的含义是注释非空,如果出现以上警告,就表明参数应该有非空标注;
如添加:
public void onReceive(@NonNull Context context, @NonNull Intent intent);
具体:
It‘s an annotation, but the correct name is NonNull:
protected void onSaveInstanceState(@NonNull Bundle outState)
(And also)
import android.support.annotation.NoNNull;
The purpose is to allow the compiler to warn when certain assumptions are being violated (such as a parameter of a method that should always have a value, as in this particular case, although there are others). From the Support Annotations documentation:
The @NonNull annotation can be used to indicate that a given parameter can not be null.
If a local variable is known to be null (for example because some earlier code checked whether it was null), and you pass that as a parameter to a method where that parameter is marked as @NonNull, the IDE will warn you that you have a potential crash.
They are tools for static analysis. Runtime behavior is not altered at all.
参考: http://stackoverflow.com/questions/24728627/meaning-of-android-studio-error-not-annotated-parameter-overrides-notnull-para
Android - Warning:Not annotated parameter overrides @NonNull parameter
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。