raw:
<?xml version="2.0" encoding="UTF-8"?>
<notificationInfos>
<notificationInfo
app_pkg="com.lili"
icon_color="lili_color"
icon_white="lili_white"
</notificationInfos> />
public static HashMap<String, int[]> readNotificationIconInfo(Context context) {
final HashMap<String, int[]> notificationIconsMap = new HashMap<String, int[]>();InputStream notiInfosStream = null;
try {
Resources res = context.getResources();
notiInfosStream = res.openRawResource(R.raw.popular3p_notification_icons);
XmlPullParser xrp = Xml.newPullParser();
xrp.setInput(notiInfosStream, "utf-8");
int colorIconId = 0;
int whiteIconId = 0;
while (xrp.getEventType() != XmlResourceParser.END_DOCUMENT) {
if (xrp.getEventType() == XmlResourceParser.START_TAG) {
if ("notificationInfo".equals(xrp.getName())) {
packageName = xrp.getAttributeValue(0);
colorIconId = res.getIdentifier(xrp.getAttributeValue(1), "drawable",
"com.android.systemui");
whiteIconId = res.getIdentifier(xrp.getAttributeValue(2), "drawable",
"com.android.systemui");
}
} else if (xrp.getEventType() == XmlPullParser.END_TAG) {
if ("notificationInfo".equals(xrp.getName())) {
int[] icons = {colorIconId, whiteIconId};
notificationIconsMap.put(packageName, icons);
}
} else if (xrp.getEventType() == XmlPullParser.TEXT) {
}
xrp.next();
}
} catch (Exception e) {
LogUtils.e(TAG, "read xml error" + e);
e.printStackTrace();
} finally {
closeQuietly(notiInfosStream);
}
return notificationIconsMap;
}
public static void closeQuietly(Closeable closeable) {
if (null != closeable) {
try {
closeable.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
634

被折叠的 条评论
为什么被折叠?



