开发者

Version Name of an APK file

开发者 https://www.devze.com 2023-02-19 04:57 出处:网络
Can i get the versionName of an APK file which is just downloaded using the intent. My code is asfollows:-

Can i get the versionName of an APK file which is just downloaded using the intent. My code is as follows:-

//downloading an APK from link  
Intent intent = new Intent(Intent.ACTION_VIEW ,Uri.parse("http://mysite/myapp.apk"));
startActivity(intent);    
开发者_如何学C

Now i want the versionName of the APK file. Can anyone help me?

Thanks Priya


Assuming you install the apk file, you can try this:

ComponentName comp = new ComponentName(pkg, cls);
PackageInfo pinfo = getPackageManager().getPackageInfo(comp.getPackageName(), 0);
versionName = pinfo.versionName;

where pkg is the name of the package, and cls is the name of the class inside of pkg.

0

精彩评论

暂无评论...
验证码 换一张
取 消