当前位置: 首页>>代码示例>>Java>>正文


Java ApplicationInfo.loadIcon方法代码示例

本文整理汇总了Java中android.content.pm.ApplicationInfo.loadIcon方法的典型用法代码示例。如果您正苦于以下问题:Java ApplicationInfo.loadIcon方法的具体用法?Java ApplicationInfo.loadIcon怎么用?Java ApplicationInfo.loadIcon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.content.pm.ApplicationInfo的用法示例。


在下文中一共展示了ApplicationInfo.loadIcon方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loadAppRow

import android.content.pm.ApplicationInfo; //导入方法依赖的package包/类
public AppRow loadAppRow(PackageManager pm, ApplicationInfo app) {
    final AppRow row = new AppRow();
    row.pkg = app.packageName;
    row.uid = app.uid;
    try {
        row.label = app.loadLabel(pm);
    } catch (Throwable t) {
        Log.e(TAG, "Error loading application label for " + row.pkg, t);
        row.label = row.pkg;
    }
    row.icon = app.loadIcon(pm);
    row.banned = getNotificationsBanned(row.pkg, row.uid);
    row.priority = getHighPriority(row.pkg, row.uid);
    row.peekable = getPeekable(row.pkg, row.uid);
    row.sensitive = getSensitive(row.pkg, row.uid);
    return row;
}
 
开发者ID:ric96,项目名称:lineagex86,代码行数:18,代码来源:NotificationBackend.java

示例2: getMediaAppsFromControllers

import android.content.pm.ApplicationInfo; //导入方法依赖的package包/类
static List<MediaAppEntry> getMediaAppsFromControllers(
        Collection<MediaController> controllers,
        PackageManager packageManager) {
    final List<MediaAppEntry> mediaApps = new ArrayList<>();
    for (final MediaController controller : controllers) {
        String packageName = controller.getPackageName();
        ApplicationInfo info;
        try {
            info = packageManager.getApplicationInfo(packageName, 0);
        } catch (NameNotFoundException e) {
            // This should not happen. If we get a media session for a package, then the
            // package must be installed on the device.
            Log.e(TAG, "Unable to load package details", e);
            continue;
        }
        final Drawable icon = info.loadIcon(packageManager);
        final String name = info.loadLabel(packageManager).toString();
        mediaApps.add(MediaAppEntry.fromSessionToken(
                controller.getSessionToken(), name,
                packageName,
                icon
        ));
    }
    return mediaApps;
}
 
开发者ID:googlesamples,项目名称:android-media-controller,代码行数:26,代码来源:LaunchActivity.java

示例3: getApkIcon

import android.content.pm.ApplicationInfo; //导入方法依赖的package包/类
public static Drawable getApkIcon(Context context, String apkPath) {
    PackageManager pm = context.getPackageManager();
    PackageInfo info = pm.getPackageArchiveInfo(apkPath,
            PackageManager.GET_ACTIVITIES);
    if (info != null) {
        ApplicationInfo appInfo = info.applicationInfo;
        appInfo.sourceDir = apkPath;
        appInfo.publicSourceDir = apkPath;
        try {
            return appInfo.loadIcon(pm);
        } catch (OutOfMemoryError e) {
            Log.e(LOG_TAG, e.toString());
        }
    }
    return null;
}
 
开发者ID:DyncKathline,项目名称:LiveGiftLayout,代码行数:17,代码来源:FileUtil.java

示例4: getApkIconThumbnail

import android.content.pm.ApplicationInfo; //导入方法依赖的package包/类
/**
 * from apk file get apk icon bitmap.
 * @param context
 * @param apkPath
 * @return
 */
public static Bitmap getApkIconThumbnail(Context context, String apkPath) {
    PackageManager pm = context.getPackageManager();
    PackageInfo info = pm.getPackageArchiveInfo(apkPath,
            PackageManager.GET_ACTIVITIES);
    Drawable drawable = null;
    if (info != null) {
        ApplicationInfo appInfo = info.applicationInfo;
        appInfo.sourceDir = apkPath;
        appInfo.publicSourceDir = apkPath;
        try {
            drawable = appInfo.loadIcon(pm);
        } catch (OutOfMemoryError e) {
            e.printStackTrace();
        }
    }
    if(drawable!=null){
        return drawableToBitmap(drawable);
    }
    return null;
}
 
开发者ID:jiajunhui,项目名称:XDisplay,代码行数:27,代码来源:Util.java

示例5: getBean

import android.content.pm.ApplicationInfo; //导入方法依赖的package包/类
/**
 * 得到AppInfo的Bean
 *
 * @param pm 包的管理
 * @param pi 包的信息
 * @return AppInfo类
 */
private static AppInfo getBean(PackageManager pm, PackageInfo pi) {
    if (pm == null || pi == null) return null;
    ApplicationInfo ai = pi.applicationInfo;
    String packageName = pi.packageName;
    String name = ai.loadLabel(pm).toString();
    Drawable icon = ai.loadIcon(pm);
    String packagePath = ai.sourceDir;
    String versionName = pi.versionName;
    int versionCode = pi.versionCode;
    boolean isSystem = (ApplicationInfo.FLAG_SYSTEM & ai.flags) != 0;
    return new AppInfo(packageName, name, icon, packagePath, versionName, versionCode, isSystem);
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:20,代码来源:AppUtils.java

示例6: loadInBackground

import android.content.pm.ApplicationInfo; //导入方法依赖的package包/类
@Override
public List<Item> loadInBackground() {
    final Context context = getContext();

    List<ApplicationInfo> infos = packageManager.getInstalledApplications(GET_NO_TAG);

    if (infos == null){
        infos = new ArrayList<>();
    }

    List<Item> items = new ArrayList<>(infos.size());
    for (ApplicationInfo info : infos) {
        String pkg = info.packageName;
        String label;
        Drawable icon;
        Intent intent;

        CharSequence sequence = info.loadLabel(context.getPackageManager());
        label = sequence  != null ? sequence.toString() : info.packageName;

        icon = info.loadIcon(context.getPackageManager());
        icon = icon != null ?
                icon
                : context.getResources().getDrawable(android.R.drawable.sym_def_app_icon,null);
        intent = packageManager.getLaunchIntentForPackage(info.packageName);

        if (packageManager.getLaunchIntentForPackage(pkg) != null){
            App app = new App(info,label,icon,intent);
            items.add(app);
        }
    }

    Collections.sort(items, Item.ALPHA_COMPARATOR);
    return items;
}
 
开发者ID:RawLauncher,项目名称:RawLauncher,代码行数:36,代码来源:AppsLoader.java

示例7: AppMarket

import android.content.pm.ApplicationInfo; //导入方法依赖的package包/类
public AppMarket(Context context, ActivityInfo activityInfo) {
    packageName = activityInfo.packageName;
    ApplicationInfo appInfo = activityInfo.applicationInfo;
    path = appInfo.publicSourceDir;
    PackageManager pm = context.getPackageManager();
    try {
        CharSequence sequence = appInfo.loadLabel(pm);
        if (sequence != null) {
            name = sequence.toString();
        }
        icon = appInfo.loadIcon(pm);
    } catch (Throwable e) {
        e.printStackTrace();
    }
}
 
开发者ID:nukc,项目名称:AppMarketUpdater,代码行数:16,代码来源:AppMarket.java

示例8: getAppIcon

import android.content.pm.ApplicationInfo; //导入方法依赖的package包/类
/**
 * Get the application icon
 *
 * @param context context
 * @return The application icon
 */
public Drawable getAppIcon(Context context) {
    try {
        //Package management operations management class
        PackageManager pm = context.getPackageManager();
        //Get the application information
        ApplicationInfo info = pm.getApplicationInfo(context.getPackageName(), 0);
        return info.loadIcon(pm);
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
    }
    return null;
}
 
开发者ID:Jusenr,项目名称:androidtools,代码行数:19,代码来源:AppUtils.java

示例9: AppInfo

import android.content.pm.ApplicationInfo; //导入方法依赖的package包/类
public AppInfo(PackageManager packageManager, ApplicationInfo applicationInfo) {
	mPackageName = applicationInfo.packageName;
	mIcon = applicationInfo.loadIcon(packageManager);
	try {
		mName = applicationInfo.loadLabel(packageManager).toString();
	} catch (Exception e) {
		mName = mPackageName;
	}
}
 
开发者ID:alescdb,项目名称:LauncherTV,代码行数:10,代码来源:AppInfo.java

示例10: setupRemoteViews

import android.content.pm.ApplicationInfo; //导入方法依赖的package包/类
private void setupRemoteViews(Context context, AppWidgetManager appWidgetManager, RemoteViews remoteViews, int widgetId, int appIndex) {
    ApplicationInfo applicationInfo = debugApps.get(appIndex);

    Drawable drawable = applicationInfo.loadIcon(context.getPackageManager());
    Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap();
    remoteViews.setImageViewBitmap(R.id.widget_image, bitmap);

    remoteViews.setTextViewText(R.id.textView, applicationInfo.packageName);

    remoteViews.setOnClickPendingIntent(R.id.actionButton, getPendingSelfIntent(context, KILL_CLICKED, widgetId, appIndex));
    remoteViews.setOnClickPendingIntent(R.id.widget_image, getPendingSelfIntent(context, IMAGE_CLICKED, widgetId, appIndex));

    appWidgetManager.updateAppWidget(widgetId, remoteViews);
}
 
开发者ID:EmmettWilson,项目名称:AppTerminator,代码行数:15,代码来源:TerminatorWidgetProvider.java

示例11: convertPackageInfoToAppData

import android.content.pm.ApplicationInfo; //导入方法依赖的package包/类
private List<AppInfo> convertPackageInfoToAppData(Context context, List<PackageInfo> pkgList, boolean fastOpen) {
    PackageManager pm = context.getPackageManager();
    List<AppInfo> list = new ArrayList<>(pkgList.size());
    String hostPkg = VirtualCore.get().getHostPkg();
    for (PackageInfo pkg : pkgList) {
        // ignore the host package
        if (hostPkg.equals(pkg.packageName)) {
            continue;
        }
        // ignore the System package
        if (isSystemApplication(pkg)) {
            continue;
        }
        ApplicationInfo ai = pkg.applicationInfo;
        String path = ai.publicSourceDir != null ? ai.publicSourceDir : ai.sourceDir;
        if (path == null) {
            continue;
        }
        AppInfo info = new AppInfo();
        info.packageName = pkg.packageName;
        info.fastOpen = fastOpen;
        info.path = path;
        info.icon = ai.loadIcon(pm);
        info.name = ai.loadLabel(pm);
        InstalledAppInfo installedAppInfo = VirtualCore.get().getInstalledAppInfo(pkg.packageName, 0);
        if (installedAppInfo != null) {
            info.cloneCount = installedAppInfo.getInstalledUsers().length;
        }
        list.add(info);
    }
    return list;
}
 
开发者ID:7763sea,项目名称:VirtualHook,代码行数:33,代码来源:AppRepository.java

示例12: loadData

import android.content.pm.ApplicationInfo; //导入方法依赖的package包/类
private void loadData(Context context, ApplicationInfo appInfo) {
    if (appInfo == null) {
        return;
    }
    PackageManager pm = context.getPackageManager();
    try {
        CharSequence sequence = appInfo.loadLabel(pm);
        if (sequence != null) {
            name = sequence.toString();
        }
        icon = appInfo.loadIcon(pm);
    } catch (Throwable e) {
        e.printStackTrace();
    }
}
 
开发者ID:7763sea,项目名称:VirtualHook,代码行数:16,代码来源:PackageAppData.java

示例13: getBean

import android.content.pm.ApplicationInfo; //导入方法依赖的package包/类
/**
 * 得到AppInfo的Bean
 *
 * @param pm 包的管理
 * @param pi 包的信息
 * @return AppInfo类
 */
private static AppInfo getBean(final PackageManager pm, final PackageInfo pi) {
    if (pm == null || pi == null) return null;
    ApplicationInfo ai = pi.applicationInfo;
    String packageName = pi.packageName;
    String name = ai.loadLabel(pm).toString();
    Drawable icon = ai.loadIcon(pm);
    String packagePath = ai.sourceDir;
    String versionName = pi.versionName;
    int versionCode = pi.versionCode;
    boolean isSystem = (ApplicationInfo.FLAG_SYSTEM & ai.flags) != 0;
    return new AppInfo(packageName, name, icon, packagePath, versionName, versionCode, isSystem);
}
 
开发者ID:Wilshion,项目名称:HeadlineNews,代码行数:20,代码来源:AppUtils.java

示例14: getBean

import android.content.pm.ApplicationInfo; //导入方法依赖的package包/类
/**
 * 得到AppInfo的Bean
 *
 * @param pm 包的管理
 * @param pi 包的信息
 * @return AppInfo类
 */
private static AppInfo getBean(PackageManager pm, PackageInfo pi) {
    ApplicationInfo ai = pi.applicationInfo;
    String name = ai.loadLabel(pm).toString();
    Drawable icon = ai.loadIcon(pm);
    String packageName = pi.packageName;
    String packagePath = ai.sourceDir;
    String versionName = pi.versionName;
    int versionCode = pi.versionCode;
    boolean isSD = (ApplicationInfo.FLAG_SYSTEM & ai.flags) != ApplicationInfo.FLAG_SYSTEM;
    boolean isUser = (ApplicationInfo.FLAG_SYSTEM & ai.flags) != ApplicationInfo.FLAG_SYSTEM;
    return new AppInfo(name, icon, packageName, packagePath, versionName, versionCode, isSD, isUser);
}
 
开发者ID:ChunweiDu,项目名称:Utils,代码行数:20,代码来源:AppUtil.java

示例15: getBean

import android.content.pm.ApplicationInfo; //导入方法依赖的package包/类
/**
 * 得到AppInfo的Bean
 */
private static AppInfo getBean(PackageManager pm, PackageInfo pi) {
    ApplicationInfo ai = pi.applicationInfo;
    String name = ai.loadLabel(pm).toString();
    Drawable icon = ai.loadIcon(pm);
    String packageName = pi.packageName;
    String versionName = pi.versionName;
    int versionCode = pi.versionCode;
    boolean isSD = (ApplicationInfo.FLAG_SYSTEM & ai.flags) != ApplicationInfo.FLAG_SYSTEM;
    boolean isUser = (ApplicationInfo.FLAG_SYSTEM & ai.flags) != ApplicationInfo.FLAG_SYSTEM;
    return new AppInfo(name, icon, packageName, versionName, versionCode, isSD, isUser);
}
 
开发者ID:zhuangzaiku,项目名称:AndroidCollection,代码行数:15,代码来源:AppUtils.java


注:本文中的android.content.pm.ApplicationInfo.loadIcon方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。