是否有可能在android中以编程方式了解设备上安装的应用程序版本(如facebook / twitter)?
...谢谢
答案 0 :(得分:5)
是的,就像这样:
String packageToCheck = "com.facebook";
List<PackageInfo> packages = getPackageManager().getInstalledPackages(0);
for (int i=0; i<packages.size(); i++) {
PackageInfo p = packages.get(i);
if (p.packageName.contains(packageToCheck)) {
String name = p.applicationInfo.loadLabel(getPackageManager()).toString();
String pname = p.applicationInfo.loadLabel(getPackageManager()).toString();
String packageName = p.packageName;
String versionName = p.versionName;
int versionCode = p.versionCode;
Log.i(TAG, name + ": " + pname + ": " + packageName + ": " + versionName + ": " + versionCode);
}
}