本文整理匯總了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);
}