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