Reputation: 21596
I wanna know if there is anyway to determine not through the packages, but through applications the version of an application which isnt the current application.
let's say right now i am in the scope of app A. and i wanna run an activity from app B. i wanna check before the version code of app B.
thanks,
ray.
Upvotes: 1
Views: 1398
Reputation: 6012
This is a method I use to verify versions and if a particular package has been installed or not:
/**
* Returns the version number we are currently in
* @param appPackageName - full name of the package of an app, 'com.dcg.meneame' for example.
*/
public static int getAppVersionCode(Context context, String appPackageName) {
if ( context!= null )
{
try {
return context.getPackageManager().getPackageInfo(appPackageName, 0).versionCode;
} catch (NameNotFoundException e) {
// App not installed!
}
}
return -1;
}
Upvotes: 4