本文整理汇总了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);
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
}
}
示例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;
}
}
示例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;
}
示例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);
}
示例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)
);
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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));
}