Skip to content
This repository was archived by the owner on Dec 17, 2023. It is now read-only.

Commit 6368b9d

Browse files
committed
fix NFE
1 parent 4bef29e commit 6368b9d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/com/android/launcher3/shortcuts/DeepShortcutManagerBackport.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ private static void parsePackageXml(Context context, String packageName, Compone
117117
}
118118

119119
if (resource != null) {
120-
parseXml = resourcesForApplication.getXml(Integer.parseInt(resource.substring(1)));
120+
int resId = resourcesForApplication.getIdentifier(resource, null, packageName);
121+
parseXml = resourcesForApplication.getXml(resId == 0 ? Integer.parseInt(resource.substring(1)) : resId);
121122
while ((eventType = parseXml.nextToken()) != XmlPullParser.END_DOCUMENT) {
122123
if (eventType == XmlPullParser.START_TAG) {
123124
if (parseXml.getName().equals("shortcut")) {
@@ -139,7 +140,7 @@ private static void parsePackageXml(Context context, String packageName, Compone
139140
}
140141
}
141142
}
142-
} catch (PackageManager.NameNotFoundException | Resources.NotFoundException | XmlPullParserException | IOException e) {
143+
} catch (PackageManager.NameNotFoundException | Resources.NotFoundException | XmlPullParserException | IOException | NumberFormatException e) {
143144
e.printStackTrace();
144145
}
145146
}

0 commit comments

Comments
 (0)