1024programmer News AndroidWarning: Notannotatedparameteroverrides@NonNullparameter

AndroidWarning: Notannotatedparameteroverrides@NonNullparameter

Warning: Not annotated parameter overrides @NonNull parameter


Address of this article: http://blog.csdn.net/caroline_wendy


Warning: The @NonNull annotation can be used to indicate that a given parameter can not be null.
The meaning of @NonNull” is that the comment is not empty. If the above warning appears, it indicates that the parameter should have a non-null label; If you add:

public void onReceive(@NonNull Context context, @NonNull Intent intent);

Specific: 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.
Reference: http://stackoverflow.com/questions/24728627/meaning-of-android-studio-error-not-annotated-parameter-overrides-notnull-para

Android – Warning: Not annotated parameter overrides @NonNull parameter


This article is from the internet and does not represent1024programmerPosition, please indicate the source when reprinting:https://www.1024programmer.com/androidwarning-notannotatedparameteroverridesnonnullparameter/

author: admin

Previous article
Next article

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索