//apkPath apk文件地址
public static Drawable getApkIcon(Context context, String apkPath) { PackageManager pm = context.getPackageManager(); PackageInfo info = pm.getPackageArchiveInfo(apkPath, PackageManager.GET_ACTIVITIES); if (info != null) { ApplicationInfo appInfo = info.applicationInfo; appInfo.sourceDir = apkPath; appInfo.publicSourceDir = apkPath; try { return appInfo.loadIcon(pm); } catch (OutOfMemoryError e) { LogUtils.e(LOG_TAG, e.toString()); } } return null; }
版权声明:本文为博主原创文章,未经博主允许不得转载。
时间: 2024-10-25 22:30:34