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.PackageManager;
import android.graphics.drawable.Drawable;

public class Main {
    public static Drawable loadIcon(Context context, int icon, String packageName) {
        PackageManager pm = context.getPackageManager();
        if (icon != 0) {
            Drawable dr = pm.getDrawable(packageName, icon, null);
            if (dr != null) {
                return dr;
            }
        }
        return pm.getDefaultActivityIcon();
    }
}