Java tutorial
//package com.java2s; import android.content.Context; public class Main { public static int tryToGetIconFormStringOrGetFromApplication(String iconName, Context context) { int iconId = context.getApplicationInfo().icon; if (null != iconName) { int customId = context.getResources().getIdentifier(iconName, "drawable", context.getPackageName()); if (0 != customId) { iconId = customId; } } return iconId; } }