0

I am trying to load a list of all installed packages on the device. However, when I do this, any installed Live Wallpapers do not show up on the list... Is there a way to fix this?

Here's my code:

final PackageManager pm = this.getPackageManager();

Intent intent = new Intent(Intent.ACTION_MAIN, null);
intent.addCategory(Intent.CATEGORY_LAUNCHER);

final ArrayList<ResolveInfo> list =
        (ArrayList<ResolveInfo>) pm.queryIntentActivities(intent,
                PackageManager.PERMISSION_GRANTED);

for (ResolveInfo rInfo : list)
{
    Log.i(TAG, ": Installed Applications " + rInfo.activityInfo.
            applicationInfo.loadLabel(pm).toString());
}

final ArrayAdapter<ResolveInfo> adapter =
    new ArrayAdapter<ResolveInfo>(this, R.layout.list_item, list)
    {
        @Override
        public View getView(int position, View convertView, ViewGroup parent)
        {
            if (convertView == null)
                convertView = LayoutInflater.from(parent.getContext()).
                    inflate(R.layout.list_item, parent, false);

            final String text = list.get(position).activityInfo.
                applicationInfo.loadLabel(pm).toString();
            ((TextView)convertView.findViewById(R.id.text)).setText(text);

            final Drawable drawable = list.get(position).activityInfo.applicationInfo.loadIcon(pm);
            ((ImageView)convertView.findViewById(R.id.image)).setImageDrawable(drawable);

            return convertView;
        }
    };

setListAdapter(adapter);
ListView lv = getListView();
lv.setTextFilterEnabled(true);
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Frank Bozzo
  • 15,033
  • 6
  • 25
  • 29

1 Answers1

6

Try this in order to get the live wallpaper apps:

List<ResolveInfo> list = mPackageManager.queryIntentServices(
            new Intent(WallpaperService.SERVICE_INTERFACE),
            PackageManager.GET_META_DATA);

Also remember that they don't have to have an activity. They could have a service instead (which they probably will, since that's how they work).

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
android developer
  • 114,585
  • 152
  • 739
  • 1,270