为什么 Android Studio Lint 在使用 TypedArray 时会发出警告?

Why does Android Studio Lint warn when using TypedArray?

我有这个代码:

TypedArray mAllowedCountries = application.getResources().obtainTypedArray(R.array.allowed_countries);

    for (int index = 0; index < mAllowedCountries.length(); index++) {
        if(mAllowedCountries.getString(index) != null) {
            if (mAllowedCountries.getString(index).toUpperCase().equals(addressComponentCountry.short_name.toUpperCase())) {
                supported = true;
                break;
            }
        }
    }

我收到关于

Android Studio Lint 警告

Method invocation 'toUpperCase' may produce 'java.lang.NullPointerException'

如何解决此问题以消除 Lint 警告?

以下应删除 Lint 警告:

final String address = addressComponentCountry.short_name.toUpperCase();
String tempStr;
for (int index = 0; index < mAllowedCountries.length(); index++) {
    tempStr = mAllowedCountries.getString(index);
    if(tempStr != null && tempStr.toUpperCase().equals(address)) {
        supported = true;
        break;
    }
}