Context pkgContext = null;
try {
pkgContext = mContext.createPackageContext(appInfo.pkgName,
Context.CONTEXT_IGNORE_SECURITY | Context.CONTEXT_INCLUDE_CODE);
} catch (NameNotFoundException e) {
Log.d(TAG, "package " + appInfo.pkgName + " is not found.");
}
Drawable icon = null;
if (pkgContext != null) {
try {
icon = pkgContext.getResources().getDrawable(appInfo.appIconRes);
} catch (NotFoundException e) {
Log.d(TAG, "Can't find app icon (" + appInfo.appIconRes + ") in package " + appInfo.pkgName);
icon = getResources().getDrawable(R.drawable.nal_icon); //TODO: modify default app icon
}
} else {
icon = getResources().getDrawable(R.drawable.nal_icon); //TODO: modify default app icon
}
String name = appInfo.pkgName;
if (pkgContext != null) {
try {
name = pkgContext.getResources().getString(appInfo.appNameRes);
} catch (NotFoundException e) {
Log.d(TAG, "Can't find app name (" + appInfo.appNameRes + ") in package " + appInfo.pkgName);
name = appInfo.pkgName;
}
}
try {
pkgContext = mContext.createPackageContext(appInfo.pkgName,
Context.CONTEXT_IGNORE_SECURITY | Context.CONTEXT_INCLUDE_CODE);
} catch (NameNotFoundException e) {
Log.d(TAG, "package " + appInfo.pkgName + " is not found.");
}
Drawable icon = null;
if (pkgContext != null) {
try {
icon = pkgContext.getResources().getDrawable(appInfo.appIconRes);
} catch (NotFoundException e) {
Log.d(TAG, "Can't find app icon (" + appInfo.appIconRes + ") in package " + appInfo.pkgName);
icon = getResources().getDrawable(R.drawable.nal_icon); //TODO: modify default app icon
}
} else {
icon = getResources().getDrawable(R.drawable.nal_icon); //TODO: modify default app icon
}
String name = appInfo.pkgName;
if (pkgContext != null) {
try {
name = pkgContext.getResources().getString(appInfo.appNameRes);
} catch (NotFoundException e) {
Log.d(TAG, "Can't find app name (" + appInfo.appNameRes + ") in package " + appInfo.pkgName);
name = appInfo.pkgName;
}
}