获取手机端已安装apk
//
public void
getInstalledApp(ArrayList
appList) {
List packages =
getPackageManager()
.getInstalledPackages(0);
for (int i =
0; i < packages.size(); i++) {
PackageInfo
packageInfo = packages.get(i);
AppDetail
tmpInfo = new AppDetail();
tmpInfo.setAppname(packageInfo.applicationInfo.loadLabel(
getPackageManager()).toString());
tmpInfo.setPackageName(packageInfo.packageName);
tmpInfo.setVersioname(packageInfo.versionName);
tmpInfo.setVersioncode(packageInfo.versionCode + "");
tmpInfo.setAppIcon(packageInfo.applicationInfo
.loadIcon(getPackageManager()));
// Only
display the non-system app info
if
((packageInfo.applicationInfo.flags &
ApplicationInfo.FLAG_SYSTEM) <= 0) {
appList.add(tmpInfo);
}
}
}
///
总结:
通过 PackageInfo 获取具体信息方法:
包名获取方法:packageInfo.packageName
icon获取获取方法:packageManager.getApplicationIcon(applicationInfo)
应用名称获取方法:packageManager.getApplicationLabel(applicationInfo)
使用权限获取方法:packageManager.getPackageInfo(packageName,PackageManager.GET_PERMISSIONS)
.requestedPermissions
通过 ResolveInfo 获取具体信息方法:
包名获取方法:resolve.activityInfo.packageName
icon获取获取方法:resolve.loadIcon(packageManager)
应用名称获取方法:resolve.loadLabel(packageManager).toString()