美文网首页
安卓开发获取未安装apk文件图标

安卓开发获取未安装apk文件图标

作者: 510bb14393e1 | 来源:发表于2022-05-04 17:46 被阅读0次
    /**
         * @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;
        }
    

    相关文章

      网友评论

          本文标题:安卓开发获取未安装apk文件图标

          本文链接:https://www.haomeiwen.com/subject/ezqgyrtx.html