Priya
Priya

Reputation: 21

Version Name of an APK file

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

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

Upvotes: 0

Views: 534

Answers (1)

Rajath
Rajath

Reputation: 11946

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.

Upvotes: 5

Related Questions