Blankj / Blankj/AndroidUtilCode
MetaDataUtils - getMetaDataInApp-NullPointerException
- Dominant language
- Java
- Stars
- 33.6k
- Forks
- 10.6k
- PR merge metrics
- No merged PRs in 30d
Description
## NullPointerException Bug
- AndroidUtilCode 的版本:
- 出现 Bug 的设备型号:
- 设备的 Android 版本:
## 相关代码
```
put your code here
```
## 异常堆栈
修改如下:
增加 if (ai != null && ai.metaData != null) 判断
```
public static String getMetaDataInApp(@NonNull final String key) {
String value = "";
PackageManager pm = Utils.getApp().getPackageManager();
String packageName = Utils.getApp().getPackageName();
try {
ApplicationInfo ai = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA);
if (ai != null && ai.metaData != null) {
value = String.valueOf(ai.metaData.get(key));
}
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
return value;
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.