I want to show icon of apk file in my listview.
How can i get icon of apk?
the icons would be in the drawable-hdpi folder. just in case you were asking where the . apk files are, look in /data/app or /system/app, depending on the app.
Finding APK Files If you want to locate the APK files in your Android phones, you can find the APK for user-installed apps under /data/app/directory while the preinstalled ones are located in /system/app folder and you can access them by using ES File Explorer.
Find Hidden Apps Through Your File Manager So, tap the relevant file manager icon to open a list of categories and tools. Go into Apps and you'll see all the programs installed on your device, as well as any Android Package Kits (APK). You can manage each item from here, too, from sharing to uninstalling it.
if (file.getPath().endsWith(".apk")) {
String filePath = file.getPath();
PackageInfo packageInfo = context.getPackageManager().getPackageArchiveInfo(filePath, PackageManager.GET_ACTIVITIES);
if(packageInfo != null) {
ApplicationInfo appInfo = packageInfo.applicationInfo;
if (Build.VERSION.SDK_INT >= 8) {
appInfo.sourceDir = filePath;
appInfo.publicSourceDir = filePath;
}
Drawable icon = appInfo.loadIcon(context.getPackageManager());
bmpIcon = ((BitmapDrawable) icon).getBitmap();
}
}
The most important line is appInfo.publicSourceDir = filePath;
This is a bug. See http://code.google.com/p/android/issues/detail?id=9151
The null check packageInfo != null
is there in case the .apk is not parsed correctly.
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