Checking external app version name in android

This worked for me:

PackageInfo pinfo = context.getPackageManager().getPackageInfo( "com.myapp", 0 );
String verName = pinfo.versionName;
int verCode = pinfo.versionCode;

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);

You should be able do this using something like this:

List<PackageInfo> packages = getPackageManager().getInstalledPackages(0);

PackageInfo mypackage = <get required app from the list>;

String versionName = mypackage.versionName;
int versionCode = mypackage.versionCode;

Have a look at PackageInfo class.

Tags:

Android