most efficient way(load speed-performance i mean) to get a list of installed apps on android?
<p>I developed an app with an activity that shows a listview of the installed apps, each row with icon, app label and checkbox. The app works fine on my nexus one and other device, but on some device, like for example an htc legend(froyo), it is extremely slow(1 minute before the activity comes up with the listview).</p>

<p>First i call the app list:</p>

<pre><code>private String[] getAppList(){
        ArrayList&lt;String&gt; results=new ArrayList&lt;String&gt;();

        PackageManager pm = this.getPackageManager();

        List&lt;ApplicationInfo&gt; list = pm.getInstalledApplications(PackageManager.GET_UNINSTALLED_PACKAGES); 
        Collections.sort(list, new ApplicationInfo.DisplayNameComparator(pm));

        boolean includeSystemApps = getIntent().getBooleanExtra("sysapps",false);

        for (ApplicationInfo AppInfo : list) 
        {
              try
              {           
                  if(includeSystemApps || ((AppInfo.flags &amp; ApplicationInfo.FLAG_SYSTEM)!=1))
                  {
                      results.add(AppInfo.packageName);
                  }
              }
              catch(Exception ex)
              {

              }
        } 

        return (String[])results.toArray(new String[results.size()]);
    }
</code></pre>

<p>Then, in the listview item adapter I load icon and label: </p>

<pre><code>String Applabel;
        try 
        {
            Applabel=pk.getApplicationLabel(pk.getApplicationInfo(data[position], 0)).toString();
        }
        catch(Exception ex)
        {
            Applabel=data[position];
        }

        holder.text.setText(Applabel);
        holder.text.setHint(data[position]);
        holder.image.setTag(data[position]);

        try
        {
            holder.image.setImageBitmap(((BitmapDrawable)pk.getApplicationIcon(data[position])).getBitmap());
        }
        catch(Exception ex)
        {
        }
</code></pre>

<p>I think the long load time, on some device, is given by this call:</p>

<pre><code>this.getPackageManager()
</code></pre>

<p>Now I don't think it's an hardware issue(cpu-ram) because the legend it's not a bad device at all.</p>

<p>But there are the crude data:</p>

<p>-nexus one(gingerbred) activity load ~1second</p>

<p>-legend(froyo) activity load ~40/60 secs!</p>

<p>Any suggestion/opinion?
Thanks in advance</p>
