tags:

views:

82

answers:

1

Hi, 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.

+1  A: 

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;
}
Moss
Yes, but then agian i need the package name.. cant i just search by app name?
rayman
As fas as I know you can not. take into account that the app name is located in a localization file (Strings.xml) so that in can change. The package name will not change.
Moss