Back to project page MaterialManager.
The source code is released under:
There is no license, someone decided to pretty much republish Cabinet with no credit so I?m taking away the license altogether.
If you think the Android project MaterialManager listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.afollestad.cabinet.utils; // w w w. j ava 2 s. com import android.content.Context; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.graphics.Bitmap; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import com.nostra13.universalimageloader.core.download.BaseImageDownloader; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; /** * Extends Universal Image Loader's image loader in order to support displaying an APK file's icon * * @author Aidan Follestad */ public class APKIconDownloader extends BaseImageDownloader { private Context mContext; public APKIconDownloader(Context context) { super(context); mContext = context; } @Override protected InputStream getStreamFromOtherSource(String path, Object extra) throws IOException { PackageManager pm = mContext.getPackageManager(); PackageInfo pi = pm.getPackageArchiveInfo(path, 0); pi.applicationInfo.sourceDir = path; pi.applicationInfo.publicSourceDir = path; Drawable apkIcon = pi.applicationInfo.loadIcon(pm); ByteArrayOutputStream stream = new ByteArrayOutputStream(); ((BitmapDrawable) apkIcon).getBitmap().compress(Bitmap.CompressFormat.PNG, 100, stream); byte[] imageInByte = stream.toByteArray(); stream.close(); return new ByteArrayInputStream(imageInByte); } }