当前位置: 首页>>代码示例>>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;未经允许,请勿转载。