Here you can find the source of getApkIcon(Context context, String apkPath)
public static Drawable getApkIcon(Context context, String apkPath)
//package com.java2s; import android.content.Context; import android.content.pm.ApplicationInfo; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.graphics.drawable.Drawable; public class Main { public static Drawable getApkIcon(Context context, String apkPath) { PackageManager pm = context.getPackageManager(); try {//from w ww . j a va2s . c o m PackageInfo info = pm.getPackageArchiveInfo(apkPath, PackageManager.GET_ACTIVITIES); if (info != null) { ApplicationInfo appInfo = info.applicationInfo; appInfo.sourceDir = apkPath; appInfo.publicSourceDir = apkPath; return appInfo.loadIcon(pm); } } catch (Exception e) { // LeLog.e("gyy:" + e.getLocalizedMessage()); } return null; } }