Wednesday, October 27, 2010

[android-developers] How to get icons of activities?

Hi,

I am trying to display a list of all activities (i.e., icon and label)
on the phone in a ListView. Here is my code to get the activities:

Intent listAppsIntent = new Intent(Intent.ACTION_MAIN, null);
listAppsIntent.addCategory(Intent.CATEGORY_LAUNCHER);
PackageManager pm = context.getPackageManager();
List<ResolveInfo> pkgAppsList =
pm.queryIntentActivities( listAppsIntent, 0);

However, when I display the list, many of the activities' icons
weren't found. I tried both of the following to get the icons to no
avail:

resolve.activityInfo.getIconResource()
resolve.activityInfo.icon

What's the proper way to do this? Thank you.

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment