I wanted to know that is it possible to find version of an apk file that i've downloaded from the server? i can retrieve the version of my app that is installed on device but i want to check installed app version on device with the downloaded apk file version.
问问题
2547 次
2 回答
2
在安装之前,您无法轻松获取下载的 APK 文件的版本。
话虽如此,您可以解压缩 APK 文件(它只是一个 zip 文件)并解析 AndroidManifest.xml 以获取版本代码的值。由于您提取的 AndroidManifest.xml 是一个二进制文件,因此您需要编写一些代码来解析它。它不像检查纯文本文件那么简单。
查看这篇文章,了解如何解析从 APK 中提取的 AndroidManifest。
于 2012-12-09T08:24:37.383 回答
1
PackageManager manager = this.getPackageManager();
PackageInfo info = manager.getPackageInfo("com.whatsapp", 0);
String packageName = info.packageName;
int versionCode = info.versionCode;
String versionName = info.versionName;
Replace com.whatsapp
with your package name.
于 2012-12-09T07:32:13.740 回答