How to use the Intent class to show the user's apps


I want my app to show the user's applications in ListView .

I have tried to investigate and the mention of this class came to me in English the problem is that it did not work out how to use it for that purpose.

Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
List<ResolveInfo> pkgAppsList = context.getPackageManager().queryIntentActivities( mainIntent, 0);

If you know please help.

asked by PowerApp 21.10.2016 в 00:30

1 answer


By means of an Intent defined as CATEGORY_LAUNCHER , you can obtain a list of installed application packages:

Intent intent = new Intent(Intent.ACTION_MAIN, null);
List listaPaquetesAppsInstaladas = getPackageManager().queryIntentActivities(intent, 0)

To add the data in a ListView , this is a complete example:

    //Crea List para almacenar packagename de las aplicaciones.
    List<String> listaPaquetesAppsInstaladas = new ArrayList<>();
    Intent intent = new Intent(Intent.ACTION_MAIN, null);

    //Obtiene datos de apps instaladas
    List<ResolveInfo> listAppsInstaladas = getPackageManager().queryIntentActivities(intent, 0);
    for(ResolveInfo info : listAppsInstaladas) {
        // be added
        ApplicationInfo applicationInfo;
        if (info == null || (applicationInfo = info.activityInfo.applicationInfo) == null
                || !applicationInfo.enabled || listaPaquetesAppsInstaladas.contains(applicationInfo.packageName)) {

    //Instancía adapter con datos obtenidos
    final ArrayAdapter adapter = new ArrayAdapter(this,
            android.R.layout.simple_list_item_1, listaPaquetesAppsInstaladas);

    //Muestra datos en ListView
    ListView listView = (ListView) findViewById(;

To obtain the application packages in ListView .

answered by 21.10.2016 в 01:09