Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.content.Context;

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

public class Main {

    public static Drawable getAppIconByPkgName(Context context, String packageName) {
        PackageManager pm = context.getPackageManager();
        Drawable drawable = null;
        try {
            drawable = pm.getApplicationIcon(packageName);
        } catch (PackageManager.NameNotFoundException mE) {
            mE.printStackTrace();
        }
        return drawable;
    }
}