Get list of installed applications that can be launched
<p>I have a custom listPreference I would like to display a list of apps that can be launched (contain an activity with CATEGORY_LAUNCHER). The selection will be used later to launch the application. When I did a search for the solution, the list also contained apps that could not be launched. Is there any way to narrow this down?</p>

<pre><code>public class AppSelectorPreference extends ListPreference {

@Override
public int findIndexOfValue(String value) {
    return 0;
    //return super.findIndexOfValue(value);
}

public AppSelectorPreference(Context context, AttributeSet attrs) {
    super(context,attrs);

    PackageManager pm = context.getPackageManager();
    List&lt;PackageInfo&gt; appListInfo = pm.getInstalledPackages(0); 
    CharSequence[] entries = new CharSequence[appListInfo.size()];
    CharSequence[] entryValues = new CharSequence[appListInfo.size()];

    try {
        int i = 0;
        for (PackageInfo p : appListInfo) {
            if (p.applicationInfo.uid &gt; 10000) {
                entries[i] = p.applicationInfo.loadLabel(pm).toString();
                entryValues[i] = p.applicationInfo.packageName.toString();              

                i++;
            }         
        }
    } catch (Exception e) {

        e.printStackTrace();
    }   

    setEntries(entries);
    setEntryValues(entryValues);
}
</code></pre>

<p>}</p>
