Checking external app version name in android

后端 未结 3 1704
清酒与你
清酒与你 2020-12-16 00:09

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

相关标签:
3条回答
  • 2020-12-16 00:18

    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.

    0 讨论(0)
  • 2020-12-16 00:22

    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);
    
    0 讨论(0)
  • 2020-12-16 00:30

    This worked for me:

    PackageInfo pinfo = context.getPackageManager().getPackageInfo( "com.myapp", 0 );
    String verName = pinfo.versionName;
    int verCode = pinfo.versionCode;
    
    0 讨论(0)
提交回复
热议问题