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);
Frank Bozzo
  • 14,503
  • 6
  • 23
  • 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) .

android developer
  • 112,189
  • 137
  • 688
  • 1,196