Android APK Information Get getApkIcon(Context context, String apkPath)

Here you can find the source of getApkIcon(Context context, String apkPath)

Description

get Apk Icon

Declaration

public static Drawable getApkIcon(Context context, String apkPath) 

Method Source Code

//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;
    }
}

Related

  1. getApplicationName(Context context)
  2. getAppName(Context context)
  3. getAppPackage(Context context)
  4. getAppVersionCode(Context context)
  5. getAppVersionName(Context context)