Android Package Manage getApplicationIcon(String packageName)

Here you can find the source of getApplicationIcon(String packageName)

Description

get Application Icon

Declaration

public static Drawable getApplicationIcon(String packageName) 

Method Source Code

//package com.java2s;

import android.app.Activity;
import android.content.pm.ApplicationInfo;

import android.content.pm.PackageManager.NameNotFoundException;
import android.graphics.drawable.Drawable;

public class Main {
    private static Activity mContext;

    public static Drawable getApplicationIcon(String packageName) {
        if (mContext == null)
            return null;

        try {//w w w  .  j av  a 2s.  c om
            return mContext.getPackageManager().getApplicationIcon(
                    packageName);
        } catch (NameNotFoundException e) {
            // TODO Auto-generated catch block
            return null;
        }
    }

    public static Drawable getApplicationIcon(ApplicationInfo ai) {
        if (mContext != null)
            return mContext.getPackageManager().getApplicationIcon(ai);
        else
            return null;
    }
}

Related

  1. getUidForPackageName(PackageManager pm, String packageName)
  2. disableComponent(PackageManager pm, ComponentName component)
  3. enableComponent(PackageManager pm, ComponentName component)
  4. isPackageInstalled(String packageName, PackageManager pm)