I have the mime-type of a particular file. I want to get the icon of the default application that opens the file. So for music, I would display the Winamp icon if that was my default music player. How can I do this?
Compose an intent with the given mime type and file URI and call PackageManager.queryIntentActivities on it.
Something like this:
final Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(fileUri);
intent.setType("image/png");
final List<ResolveInfo> matches = getPackageManager().queryIntentActivities(intent, 0);
for (ResolveInfo match : matches) {
final Drawable icon = match.loadIcon(getPackageManager());
final CharSequence label = match.loadLabel(getPackageManager());
}
-
I haven't been in to work because of the holiday so I'll post back Monday, thanks! – benkdev Nov 27 '11 at 19:15
-
This worked to get the default icon. When displaying in my app, the padding around the icon drawables is different. I'm displaying them in a list so now I've got to figure out how to get uniform padding. – benkdev Nov 28 '11 at 18:15