Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import android.content.Context;

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

public class Main {
    public static Drawable getAppIcon(Context mContext, String packageName) {
        try {
            PackageManager manager = mContext.getPackageManager();
            PackageInfo info = manager.getPackageInfo(packageName, 0);
            Drawable drawable = info.applicationInfo.loadIcon(manager);
            return drawable;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}