Java tutorial
//package com.java2s; import android.content.Context; public class Main { private static int getIconId(Context context, String targetPackage, String iconName) { if (targetPackage.equals(context.getPackageName())) { return context.getResources().getIdentifier(iconName, "drawable", targetPackage); } return 0; } }