获取包含activity应用的信息
PackageManager pm = getPackageManager();
Intent mainIntent = new Intent(Intent. ACTION_MAIN, null );
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
List<ResolveInfo> resolveInfos = pm
.queryIntentActivities(mainIntent, 0);
appList.clear();
for (ResolveInfo reInfo : resolveInfos) {
LogExt. LogD(this, Thread. currentThread().getStackTrace(),
"reInfo.activityInfo.name=" + reInfo.activityInfo.name );
String activityName = reInfo. activityInfo.name ;
String appLabel = (String) reInfo.loadLabel(pm);
Drawable icon = reInfo.loadIcon(pm);
AppInfo tmpInfo = new AppInfo();
tmpInfo. appName = appLabel;
tmpInfo. packageName = reInfo.activityInfo .packageName ;
tmpInfo. mainActivityName = activityName;
tmpInfo. appIcon = icon;
appList.add(tmpInfo);
}
获取所有的App信息
PackageManager pm = getPackageManager();
List<PackageInfo> packages = pm
.getInstalledPackages(PackageManager. MATCH_DEFAULT_ONLY);
LogExt.LogD (this , Thread.currentThread ().getStackTrace(),
"packages.size() = " + packages.size());
appList.clear();
for (int i = 0; i < packages.size(); i++) {
PackageInfo packageInfo = packages.get(i);
AppInfo tmpInfo = new AppInfo();
tmpInfo. appName = packageInfo.applicationInfo .loadLabel(
getPackageManager()).toString();
tmpInfo. packageName = packageInfo.packageName ;
tmpInfo. versionName = packageInfo.versionName ;
tmpInfo. versionCode = packageInfo.versionCode ;
tmpInfo. appIcon = packageInfo.applicationInfo
.loadIcon(getPackageManager());
appList.add(tmpInfo);
}