android - Deference of 'response.body()' may produce 'java.lang.NullPointerException -
this question has answer here:
- what nullpointerexception, , how fix it? 12 answers
i have error. name value string type. settext string type have error.
factory.getinstance().placeholdermodel().enqueue(new callback<placeholdermodel>() { @override public void onresponse(call<placeholdermodel> call, response<placeholdermodel> response) { textview.settext(response.body().name); }
thank
your advice important me
it's warning not error, prevent use
if (response.body != null ) {}
or use annotation
@ header of method @nonnull
denotes parameter, field or method return value can never null.
public void onresponse(@nonnull call<placeholdermodel> call, response<placeholdermodel> response) {
Comments
Post a Comment