在安卓设备上,是否有可能通过编程方式了解应用程序(例如Facebook/Twitter)的版本?
谢谢...
是的,就像这样:
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);
}
}