Reputation: 51
I know how to get the icon of an 'installed' android application BUT I need to retrieve the icon of an application which is not installed (I have the android package name of the app). Does google offer any public service to retrieve this? (I believe Apple does provide that for iOS apps).
Upvotes: 2
Views: 374
Reputation: 10076
I have used this code in my project which can help you,How you can get icon follow below code:
ImageView imageViewAPK = (ImageView)findViewById(R.id.imageView_apk);
File file = new File("/mnt/sdcard/path/to/your/app.apk");
String sourcePath = file.getPath();
if (sourcePath.endsWith(".apk")) {
PackageInfo packageInfo = getPackageManager()
.getPackageArchiveInfo(sourcePath, PackageManager.GET_ACTIVITIES);
if(packageInfo != null) {
ApplicationInfo appInfo = packageInfo.applicationInfo;
if (Build.VERSION.SDK_INT >= 8) {
appInfo.sourceDir = sourcePath;
appInfo.publicSourceDir = sourcePath;
}
Drawable icon = appInfo.loadIcon(getPackageManager());
Bitmap bmpIcon = ((BitmapDrawable) icon).getBitmap();
imageViewAPK.setImageBitmap(bmpIcon);
}
}
Upvotes: 1