Methods Summary |
---|
public static android.graphics.drawable.Drawable | getApplicationIcon(android.content.Context context, android.content.pm.ApplicationInfo appInfo)
return appInfo.loadIcon(context.getPackageManager());
|
public static android.content.pm.ApplicationInfo | getApplicationInfo(android.net.Uri packageURI)
/*
* Utility method to get application information for a given packageURI
*/
final String archiveFilePath = packageURI.getPath();
PackageParser packageParser = new PackageParser(archiveFilePath);
File sourceFile = new File(archiveFilePath);
DisplayMetrics metrics = new DisplayMetrics();
metrics.setToDefaults();
PackageParser.Package pkg = packageParser.parsePackage(sourceFile, archiveFilePath, metrics, 0);
if (pkg == null) {
return null;
}
return pkg.applicationInfo;
|
public static java.lang.CharSequence | getApplicationLabel(android.content.Context context, android.content.pm.ApplicationInfo appInfo)
CharSequence appName = appInfo.loadLabel(context.getPackageManager());
if(appName == null) {
appName = context.getString(R.string.unknown);
}
return appName;
|
public static PackageParser.Package | getPackageInfo(android.net.Uri packageURI)
final String archiveFilePath = packageURI.getPath();
PackageParser packageParser = new PackageParser(archiveFilePath);
File sourceFile = new File(archiveFilePath);
DisplayMetrics metrics = new DisplayMetrics();
metrics.setToDefaults();
return packageParser.parsePackage(sourceFile, archiveFilePath, metrics, 0);
|
public static android.view.View | initAppSnippet(android.app.Activity context, android.content.pm.ApplicationInfo appInfo, int snippetId)
View appSnippet = context.findViewById(snippetId);
((ImageView)appSnippet.findViewById(R.id.app_icon)).setImageDrawable(
getApplicationIcon(context, appInfo));
((TextView)appSnippet.findViewById(R.id.app_name)).setText(
getApplicationLabel(context, appInfo));
return appSnippet;
|
public static boolean | isPackageAlreadyInstalled(android.app.Activity context, java.lang.String pkgName)
List<PackageInfo> installedList = context.getPackageManager().getInstalledPackages(
PackageManager.GET_UNINSTALLED_PACKAGES);
int installedListSize = installedList.size();
for(int i = 0; i < installedListSize; i++) {
PackageInfo tmp = installedList.get(i);
if(pkgName.equalsIgnoreCase(tmp.packageName)) {
return true;
}
}
return false;
|