Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Checking external app version name in android

Tags:

android

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;

Of course with try/catch surrounded.

like image 810
Dim Avatar asked Jan 24 '12 14:01

Dim


1 Answers

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);
like image 141
Maxim Avatar answered Oct 05 '22 23:10

Maxim