I have a small code which gives an incorrect lint warning:
int myfunc(@Nullable valStr) {
int val = -1;
if (!TextUtils.isEmpty(valStr)) {
try {
val = valStr.startsWith("1-"); //<== lint warning here : NullPointerException
} catch (Exception e) {
}
}
return val;
}
This code gives lint warning that says valStr
may be null
which is impossible because I have checked valStr
with TextUtils.isEmpty()
. How I can disable this warning for the if
block statement?I don't want to disable it for the whole function with @SuppressLint
.