title: How can I get the icons of the applications in a list?
body: <p>I am trying to make a listview with chechboxes for the installed applications on the android phone.
  I put the icons in an ArrayList as follows</p>
  
  <pre><code>packs = new ArrayList&lt;String&gt;(); // a list of all the packages
  names = new ArrayList&lt;String&gt;(); // a list of all the apps names
  icons = new ArrayList&lt;Drawable&gt;(); // a list of all apps drawable images
  List&lt;ApplicationInfo&gt; packages = packageManager.getInstalledApplications(PackageManager.GET_META_DATA);
  for (ApplicationInfo packageInfo : packages) {
      if ((packageInfo.flags &amp; ApplicationInfo.FLAG_SYSTEM) !=1){ // 'if' is to remove all system applications
      packs.add((String) packageInfo.packageName);
      names.add((String) packageManager.getApplicationLabel(packageInfo));
      icons.add((Drawable) packageManager.getApplicationIcon(packageInfo));
  </code></pre>
  
  <p>Then to put it on the listview, i use this.</p>
  
  <pre><code>icon = (ImageView) row.findViewById(R.id.appIcon);
  
  icon.setImageDrawable(icons.get(position));
  </code></pre>
  
  <p>However, it force closes and The problem is in icon.setImageDrawable(icons.get(position));
  How can I solve it?</p>