/**
* @param context
* @param apkPath apk文件路径
* @return
*/
public static Drawable getApkIcon(Context context, String apkPath) {
PackageManager packageManager = context.getPackageManager();
PackageInfo packageInfo = packageManager.getPackageArchiveInfo(apkPath, PackageManager.GET_ACTIVITIES);
if (packageInfo != null) {
ApplicationInfo info = packageInfo.applicationInfo;
info.sourceDir = apkPath;
info.publicSourceDir = apkPath;
try {
return info.loadIcon(packageManager);
} catch (Exception e) {
}
}
return null;
}
网友评论