當前位置: 首頁>>代碼示例>>Java>>正文


Java ActivityInfo.getIconResource方法代碼示例

本文整理匯總了Java中android.content.pm.ActivityInfo.getIconResource方法的典型用法代碼示例。如果您正苦於以下問題:Java ActivityInfo.getIconResource方法的具體用法?Java ActivityInfo.getIconResource怎麽用?Java ActivityInfo.getIconResource使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.content.pm.ActivityInfo的用法示例。


在下文中一共展示了ActivityInfo.getIconResource方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getFullResIcon

import android.content.pm.ActivityInfo; //導入方法依賴的package包/類
/**
 * 根據ActivityInfo繪製圖標
 * @param info
 * @return
 */
public Drawable getFullResIcon(ActivityInfo info) {
    Resources resources;
    try {
        resources = mPackageManager.getResourcesForApplication(
                info.applicationInfo);
    } catch (PackageManager.NameNotFoundException e) {
        resources = null;
    }
    if (resources != null) {
        int iconId = info.getIconResource();
        if (iconId != 0) {
            return getFullResIcon(resources, iconId);
        }
    }

    return getFullResDefaultActivityIcon();
}
 
開發者ID:TeamBrainStorm,項目名稱:SimpleUILauncher,代碼行數:23,代碼來源:IconCache.java

示例2: getFullResIcon

import android.content.pm.ActivityInfo; //導入方法依賴的package包/類
public Drawable getFullResIcon(ActivityInfo info) {
    Resources resources;
    try {
        resources = mPackageManager.getResourcesForApplication(
                info.applicationInfo);
    } catch (PackageManager.NameNotFoundException e) {
        resources = null;
    }
    if (resources != null) {
        int iconId = info.getIconResource();
        if (iconId != 0) {
            return getFullResIcon(resources, iconId);
        }
    }

    return getFullResDefaultActivityIcon();
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:18,代碼來源:IconCache.java

示例3: getActivityIcon

import android.content.pm.ActivityInfo; //導入方法依賴的package包/類
/**
 * Gets the activity or application icon for an activity.
 *
 * @param component Name of an activity.
 * @return A drawable, or {@code null} if neither the acitivy or the application
 *         have an icon set.
 */
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;
}
 
開發者ID:treasure-lau,項目名稱:CSipSimple,代碼行數:28,代碼來源:SuggestionsAdapter.java

示例4: getActivityIcon

import android.content.pm.ActivityInfo; //導入方法依賴的package包/類
private Drawable getActivityIcon(ComponentName component) {
    PackageManager pm = this.mContext.getPackageManager();
    try {
        ActivityInfo activityInfo = pm.getActivityInfo(component, 128);
        int iconId = activityInfo.getIconResource();
        if (iconId == 0) {
            return null;
        }
        Drawable drawable = pm.getDrawable(component.getPackageName(), iconId, activityInfo.applicationInfo);
        if (drawable != null) {
            return drawable;
        }
        Log.w(LOG_TAG, "Invalid icon resource " + iconId + " for " + component.flattenToShortString());
        return null;
    } catch (NameNotFoundException ex) {
        Log.w(LOG_TAG, ex.toString());
        return null;
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:20,代碼來源:SuggestionsAdapter.java


注:本文中的android.content.pm.ActivityInfo.getIconResource方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。