检查Android中的外部应用程序版本名称 [英] Checking external app version name in android
本文介绍了检查Android中的外部应用程序版本名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道如何阅读已安装的apk版本. 例如,从我的应用程序中,我想知道我的手机上安装了什么版本的Skype.
I would like to know how to read installed apk version. For example, from my app i would like to know what version of Skype is installed on my phone.
要阅读我的应用程序版本,请使用:
To Read my app version i use:
PackageInfo pinfo = null;
pinfo = getPackageManager().getPackageInfo(getPackageName(), 0);
String versionName = pinfo.versionName;
当然还有try/catch.
Of course with try/catch surrounded.
推荐答案
您需要确定设备上安装的Skype的正确软件包名称是什么.
You need to figure out what is the right package name of the skype installed on your device.
PackageInfo pinfo = null;
pinfo = getPackageManager().getPackageInfo("com.skype.android", 0);
//getVersionCode is Deprecated, instead use getLongVersionCode().
long verCode = pinfo.getLongVersionCode();
//getVersionName is Deprecated, instead use versionName
String verName = pinfo.versionName;
您可以通过以下方法调用获取所有软件包并找出名称:
You can get all packages and find out name with the following method call:
List<PackageInfo> packages = getPackageManager().getInstalledPackages(PackageManager.GET_META_DATA);
这篇关于检查Android中的外部应用程序版本名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文