I'm developing an Winform application using aapt to get some info from apk file. I got the path of application icon, something like this: *res/drawable-mdpi/app_icon.png* I want to get the icon from its path and push it to an ImageList. How can i do it? Thanks advanced!
Get icon from APK file:
File file = new File("/mnt/sdcard/thinkandroidsimple/pam.apk");
String sourcePath = file.getPath();
if (sourcePath.endsWith(".apk")) {
PackageInfo packageInfo = context.getPackageManager()
.getPackageArchiveInfo(filePath, 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(context.getPackageManager());
Bitmap bmpIcon = ((BitmapDrawable) icon).getBitmap();
}
}
See details: How to get Icon from APK files in Android
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