Is there a way I can get application name, application version and application icon, for the package that is not yet installed? (for some apk file on sdcard)
I just spent more hours than I'll ever admit looking for the solution to this.. and found it! :) :)
After wandering into this reference: http://code.google.com/p/android/issues/detail?id=9151 I found out the trick to obtaining the icon and name(label, that is) from .apk files that have NOT BEEN INSTALLED.
I hope it's not too late to help others with this:
String APKFilePath = "mnt/sdcard/myapkfile.apk"; //For example...
PackageManager pm = getPackageManager();
PackageInfo pi = pm.getPackageArchiveInfo(APKFilePath, 0);
// the secret are these two lines....
pi.applicationInfo.sourceDir = APKFilePath;
pi.applicationInfo.publicSourceDir = APKFilePath;
//
Drawable APKicon = pi.applicationInfo.loadIcon(pm);
String AppName = (String)pi.applicationInfo.loadLabel(pm);
After light testing this, it seems to work... whew.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With