private Drawable getActivityIcon ( ComponentName component ) { PackageManager pm = mContext . getPackageManager ( ) ; final ActivityInfo activityInfo ; try { activityInfo = pm . getActivityInfo ( component , PackageManager . GET_META_DATA ) ; } catch ( NameNotFoundException ex ) { Log . w ( LOG_TAG , ex . toString ( ) ) ; return null ; } int iconId = activityInfo . getIconResource ( ) ; if ( iconId == 0 ) return null ; String pkg = component . getPackageName ( ) ; Drawable drawable = pm . getDrawable ( pkg , iconId , activityInfo . applicationInfo ) ; if ( drawable == null ) { Log . w ( LOG_TAG , "Invalid icon resource " + iconId + " for " + component . flattenToShortString ( ) ) ; return null ; } return drawable ; }
Gets the activity or application icon for an activity .