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


Java ResolveInfo.loadIcon方法代碼示例

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


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

示例1: App

import android.content.pm.ResolveInfo; //導入方法依賴的package包/類
public App(ResolveInfo info, Context ctx){
    PackageManager pm = ctx.getPackageManager();
    this.name = info.loadLabel(pm).toString();
    this.packageName = info.activityInfo.packageName;
    this.className = info.activityInfo.name;
    this.icon = info.loadIcon(pm);
}
 
開發者ID:jathak,項目名稱:sflauncher,代碼行數:8,代碼來源:App.java

示例2: loadIconForResolveInfo

import android.content.pm.ResolveInfo; //導入方法依賴的package包/類
Drawable loadIconForResolveInfo(ResolveInfo ri) {
    Drawable dr;
    try {
        if (ri.resolvePackageName != null && ri.icon != 0) {
            dr = getIcon(mPm.getResourcesForApplication(ri.resolvePackageName), ri.icon);
            if (dr != null) {
                return dr;
            }
        }
        final int iconRes = ri.getIconResource();
        if (iconRes != 0) {
            dr = getIcon(mPm.getResourcesForApplication(ri.activityInfo.packageName), iconRes);
            if (dr != null) {
                return dr;
            }
        }
    } catch (PackageManager.NameNotFoundException e) {
        VLog.e(TAG, "Couldn't find resources for package\n" + VLog.getStackTraceString(e));
    }
    return ri.loadIcon(mPm);
}
 
開發者ID:7763sea,項目名稱:VirtualHook,代碼行數:22,代碼來源:ResolverActivity.java

示例3: getShareAppList

import android.content.pm.ResolveInfo; //導入方法依賴的package包/類
private List<AppBean> getShareAppList() {
        List<AppBean> shareAppInfos = new ArrayList<AppBean>();
        PackageManager packageManager = getPackageManager();
        List<ResolveInfo> resolveInfos = getShareApps(RecyclerVireWithBottomSheetDialogActivity.this);
        if (null == resolveInfos) {
            return null;
        } else {
            for (ResolveInfo resolveInfo : resolveInfos) {
                AppBean appBean = new AppBean();
                appBean.pkgName = (resolveInfo.activityInfo.packageName);
//              Log.i("getShareAppList", "pkg>" + resolveInfo.activityInfo.packageName + ";name>" + resolveInfo.activityInfo.name);
                appBean.appLauncherClassName = (resolveInfo.activityInfo.name);
                appBean.appName = (resolveInfo.loadLabel(packageManager).toString());
                appBean.icon = (resolveInfo.loadIcon(packageManager));
                shareAppInfos.add(appBean);
            }
        }
        return shareAppInfos;
    }
 
開發者ID:AweiLoveAndroid,項目名稱:BottomSheetDialogDemo,代碼行數:20,代碼來源:RecyclerVireWithBottomSheetDialogActivity.java

示例4: getShareAppList

import android.content.pm.ResolveInfo; //導入方法依賴的package包/類
private List<AppBean> getShareAppList() {
        List<AppBean> shareAppInfos = new ArrayList<AppBean>();
        PackageManager packageManager = activity.getPackageManager();
        List<ResolveInfo> resolveInfos = getShareApps(activity);
        if (null == resolveInfos) {
            return null;
        } else {
            for (ResolveInfo resolveInfo : resolveInfos) {
                AppBean appBean = new AppBean();
                appBean.pkgName = (resolveInfo.activityInfo.packageName);
//              showLog_I(TAG, "pkg>" + resolveInfo.activityInfo.packageName + ";name>" + resolveInfo.activityInfo.name);
                appBean.appLauncherClassName = (resolveInfo.activityInfo.name);
                appBean.appName = (resolveInfo.loadLabel(packageManager).toString());
                appBean.icon = (resolveInfo.loadIcon(packageManager));
                shareAppInfos.add(appBean);
            }
        }
        return shareAppInfos;
    }
 
開發者ID:AweiLoveAndroid,項目名稱:BottomSheetDialogDemo,代碼行數:20,代碼來源:ShareRecyclerViewAdapter.java

示例5: loadIconForResolveInfo

import android.content.pm.ResolveInfo; //導入方法依賴的package包/類
Drawable loadIconForResolveInfo(ResolveInfo ri) {
    Drawable dr;
    try {
        if (ri.resolvePackageName != null && ri.icon != 0) {
            dr = getIcon(mPm.getResourcesForApplication(ri.resolvePackageName), ri.icon);
            if (dr != null) {
                return dr;
            }
        }
        final int iconRes = ri.getIconResource();
        if (iconRes != 0) {
            dr = getIcon(mPm.getResourcesForApplication(ri.activityInfo.packageName), iconRes);
            if (dr != null) {
                return dr;
            }
        }
    } catch (PackageManager.NameNotFoundException e) {
        VLog.e(TAG, "Couldn't find resources for package\n"+VLog.getStackTraceString(e));
    }
    return ri.loadIcon(mPm);
}
 
開發者ID:codehz,項目名稱:container,代碼行數:22,代碼來源:ResolverActivity.java

示例6: queryAppInfo

import android.content.pm.ResolveInfo; //導入方法依賴的package包/類
public void queryAppInfo() {
    PackageManager pm = this.getPackageManager(); // 獲得PackageManager對象
    Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
    mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
    List<ResolveInfo> resolveInfos = pm.queryIntentActivities(mainIntent, 0);
    Collections.sort(resolveInfos, new ResolveInfo.DisplayNameComparator(pm));
    if (AppProxyManager.Instance.mlistAppInfo != null) {
        AppProxyManager.Instance.mlistAppInfo.clear();
        for (ResolveInfo reInfo : resolveInfos) {
            String pkgName = reInfo.activityInfo.packageName; // 獲得應用程序的包名
            String appLabel = (String) reInfo.loadLabel(pm); // 獲得應用程序的Label
            Drawable icon = reInfo.loadIcon(pm); // 獲得應用程序圖標
            AppInfo appInfo = new AppInfo();
            appInfo.setAppLabel(appLabel);
            appInfo.setPkgName(pkgName);
            appInfo.setAppIcon(icon);
            if (!appInfo.getPkgName().equals("com.vm.shadowsocks"))//App本身會強製加入代理列表
                AppProxyManager.Instance.mlistAppInfo.add(appInfo);
        }
    }
}
 
開發者ID:IronMan001,項目名稱:ss-android,代碼行數:22,代碼來源:AppManager.java

示例7: AppInfo

import android.content.pm.ResolveInfo; //導入方法依賴的package包/類
AppInfo(PackageManager packageManager, ResolveInfo resolveInfo) {
	mPackageName = resolveInfo.activityInfo.packageName;
	mIcon = resolveInfo.loadIcon(packageManager);
	try {
		mName = resolveInfo.loadLabel(packageManager).toString();
	} catch (Exception e) {
		mName = mPackageName;
	}
}
 
開發者ID:alescdb,項目名稱:LauncherTV,代碼行數:10,代碼來源:AppInfo.java

示例8: getIcon

import android.content.pm.ResolveInfo; //導入方法依賴的package包/類
/**
 * Get Activity icon
 */
public static Drawable getIcon(PackageManager pkgManager, String pkgName, String activity) {
    if (pkgManager  == null || TextUtils.isEmpty(pkgName) || TextUtils.isEmpty(activity)) {
        return null;
    }

    Intent intent = new Intent();
    intent.setClassName(pkgName, activity);
    ResolveInfo resolveInfo = pkgManager.resolveActivity(intent, 0);
    if (resolveInfo != null) {
        return resolveInfo.loadIcon(pkgManager);
    }
    return null;
}
 
開發者ID:homeii,項目名稱:GxIconDIY,代碼行數:17,代碼來源:PkgUtil.java

示例9: loadIconForResolveInfo

import android.content.pm.ResolveInfo; //導入方法依賴的package包/類
private Drawable loadIconForResolveInfo(ResolveInfo info) {
    try {
        final int iconRes = info.getIconResource();
        if (iconRes != 0) {
            Resources res = mManager.getResourcesForApplication(info.activityInfo.packageName);
            Drawable icon = ApiCompatibilityUtils.getDrawable(res, iconRes);
            return icon;
        }
    } catch (NameNotFoundException | NotFoundException e) {
        // Could not find the icon. loadIcon call below will return the default app icon.
    }
    return info.loadIcon(mManager);
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:14,代碼來源:ShareDialogAdapter.java

示例10: load

import android.content.pm.ResolveInfo; //導入方法依賴的package包/類
@Override
public AdaptiveIcon load(Context context, ResolveInfo info) {
    Drawable foreground;
    try {
        foreground = info.loadIcon(context.getPackageManager());
    } catch (Exception e) {
        if (getFallback() != null)
            return getFallback().load(context, info);
        else {
            if (BuildConfig.DEBUG)
                Log.e("AdaptiveIcon", "LegacyIconFallback threw \n"
                        + e.getClass().getName() + ": " + e.getMessage()
                        + "\n without a fallback, returning null");
            return null;
        }
    }

    Bitmap fgBitmap = ImageUtils.drawableToBitmap(foreground);
    if (removeShadow)
        fgBitmap = ImageUtils.removeShadow(fgBitmap);

    return new AdaptiveIcon(
            fgBitmap,
            shouldClip != null && !shouldClip ? null : ImageUtils.drawableToBitmap(background != null ? background : new ColorDrawable(ImageUtils.getDominantColor(fgBitmap))),
            scale != null ? scale : (ImageUtils.hasTransparency(fgBitmap) ? 1.25 : 1)
    );
}
 
開發者ID:TheAndroidMaster,項目名稱:AdaptiveIconView,代碼行數:28,代碼來源:AdaptiveIcon.java

示例11: getIcon

import android.content.pm.ResolveInfo; //導入方法依賴的package包/類
/**
 * Get Activity icon
 */
public static Drawable getIcon(PackageManager pkgManager, String pkgName, String activity) {
    if (pkgManager == null || TextUtils.isEmpty(pkgName) || TextUtils.isEmpty(activity)) {
        return null;
    }

    Intent intent = new Intent();
    intent.setClassName(pkgName, activity);
    ResolveInfo resolveInfo = pkgManager.resolveActivity(intent, 0);
    if (resolveInfo != null) {
        return resolveInfo.loadIcon(pkgManager);
    }
    return null;
}
 
開發者ID:uchiaitachipro,項目名稱:icon_pack_loader,代碼行數:17,代碼來源:PkgUtils.java

示例12: create

import android.content.pm.ResolveInfo; //導入方法依賴的package包/類
static ShareItem create(Context context, ResolveInfo resolveInfo) {
    final PackageManager pm = context.getPackageManager();
    final CharSequence label = resolveInfo.loadLabel(pm);
    final Drawable drawable = resolveInfo.loadIcon(pm);

    final ShareDescription shareDescription = new ShareDescription(drawable, label);
    final ComponentName componentName = new ComponentName(
            resolveInfo.activityInfo.packageName,
            resolveInfo.activityInfo.name
    );
    return new SystemShareItem(shareDescription, componentName);
}
 
開發者ID:roshakorost,項目名稱:Phial,代碼行數:13,代碼來源:ShareItem.java

示例13: IconPackInfo

import android.content.pm.ResolveInfo; //導入方法依賴的package包/類
IconPackInfo(ResolveInfo r, PackageManager packageManager) {
    packageName = r.activityInfo.packageName;
    icon = r.loadIcon(packageManager);
    label = r.loadLabel(packageManager);
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:6,代碼來源:IconsManager.java

示例14: getDefaultIconForPackage

import android.content.pm.ResolveInfo; //導入方法依賴的package包/類
/**
 * This method will first try to look up the icon in the AppFilterMap.
 * If no icon is found in the AppFilter, a masked icon will be generated for this app.
 *
 * @param info
 * @param maskFallback
 * @return
 */
@WorkerThread
public Drawable getDefaultIconForPackage(ResolveInfo info, boolean maskFallback) {

    if (!mAppFilterLoaded) {
        throw new AppFilterNotLoadedException();
    }

    String appPackageName = info.activityInfo.packageName;

    PackageManager pm = mContextReference.get().getPackageManager();

    Drawable defaultIcon = info.loadIcon(pm);

    Intent launchIntent = pm.getLaunchIntentForPackage(appPackageName);

    String componentName = null;

    if (launchIntent != null) {
        componentName = pm.getLaunchIntentForPackage(appPackageName).getComponent().toString();
    }

    String drawableName = mAppFilterMap.get(componentName);

    if (drawableName != null) {

        // found in app filter

        Drawable drawable = loadDrawable(drawableName);

        if (drawable == null) {
            return maskFallback ? generateMaskedIcon(defaultIcon) : defaultIcon;
        } else {
            return drawable;
        }

    } else {

        // not found

        // try to get a resource with the component filename
        if (componentName != null) {
            int start = componentName.indexOf("{") + 1;
            int end = componentName.indexOf("}", start);
            if (end > start) {
                drawableName = componentName.substring(start, end).toLowerCase(Locale.getDefault()).replace(".", "_").replace("/", "_");

                if (ResourceHelper.getDrawableResourceId(mPackResources, drawableName, mPackageName) > 0)
                    return loadDrawable(drawableName);
            }
        }
    }

    return (maskFallback && mIconMasking != null) ? generateMaskedIcon(defaultIcon) : defaultIcon;
}
 
開發者ID:sofakingforever,項目名稱:IconPackParser-Android,代碼行數:63,代碼來源:IconPack.java

示例15: toDictChoiceItem

import android.content.pm.ResolveInfo; //導入方法依賴的package包/類
private @NonNull DictChoiceItem toDictChoiceItem(@NonNull ResolveInfo ri) {
    return new DictChoiceItem(ri.activityInfo.packageName,
            ri.loadLabel(mPkgMgr),
            ri.loadIcon(mPkgMgr));
}
 
開發者ID:orionlee,項目名稱:aDictOnCopy,代碼行數:6,代碼來源:DictionaryManager.java


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