本文整理汇总了Java中android.content.pm.ResolveInfo.getIconResource方法的典型用法代码示例。如果您正苦于以下问题:Java ResolveInfo.getIconResource方法的具体用法?Java ResolveInfo.getIconResource怎么用?Java ResolveInfo.getIconResource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.pm.ResolveInfo
的用法示例。
在下文中一共展示了ResolveInfo.getIconResource方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadIconForResolveInfo
import android.content.pm.ResolveInfo; //导入方法依赖的package包/类
Drawable loadIconForResolveInfo(ResolveInfo ri) {
Drawable dr;
try {
if (ri.resolvePackageName != null && ri.icon != 0) {
dr = getIcon(mPm.getResourcesForApplication(ri.resolvePackageName), ri.icon);
if (dr != null) {
return dr;
}
}
final int iconRes = ri.getIconResource();
if (iconRes != 0) {
dr = getIcon(mPm.getResourcesForApplication(ri.activityInfo.packageName), iconRes);
if (dr != null) {
return dr;
}
}
} catch (PackageManager.NameNotFoundException e) {
VLog.e(TAG, "Couldn't find resources for package\n" + VLog.getStackTraceString(e));
}
return ri.loadIcon(mPm);
}
示例2: loadIconForResolveInfo
import android.content.pm.ResolveInfo; //导入方法依赖的package包/类
Drawable loadIconForResolveInfo(ResolveInfo ri) {
Drawable dr;
try {
if (ri.resolvePackageName != null && ri.icon != 0) {
dr = getIcon(mPm.getResourcesForApplication(ri.resolvePackageName), ri.icon);
if (dr != null) {
return dr;
}
}
final int iconRes = ri.getIconResource();
if (iconRes != 0) {
dr = getIcon(mPm.getResourcesForApplication(ri.activityInfo.packageName), iconRes);
if (dr != null) {
return dr;
}
}
} catch (PackageManager.NameNotFoundException e) {
VLog.e(TAG, "Couldn't find resources for package\n"+VLog.getStackTraceString(e));
}
return ri.loadIcon(mPm);
}
示例3: loadIconForResolveInfo
import android.content.pm.ResolveInfo; //导入方法依赖的package包/类
private Drawable loadIconForResolveInfo(ResolveInfo info) {
try {
final int iconRes = info.getIconResource();
if (iconRes != 0) {
Resources res = mManager.getResourcesForApplication(info.activityInfo.packageName);
Drawable icon = ApiCompatibilityUtils.getDrawable(res, iconRes);
return icon;
}
} catch (NameNotFoundException | NotFoundException e) {
// Could not find the icon. loadIcon call below will return the default app icon.
}
return info.loadIcon(mManager);
}