Created
October 10, 2014 02:07
-
-
Save MikeAfc/e81f320d456ceba362ec to your computer and use it in GitHub Desktop.
get bitmap icon from apk file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment