I'm trying to learn how to build a list of all installed Android applications. How do I show in a ListView
all the applications installed on the smartphone?
I'm trying to learn how to build a list of all installed Android applications. How do I show in a ListView
all the applications installed on the smartphone?
Following the code to get the list of activities / applications installed on Android:
final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
final List pkgAppsList = context.getPackageManager().queryIntentActivities( mainIntent, 0);
I hope it has helped, any questions just call.
Follows:
PackageManager packageManager=getPackageManager();
List<ApplicationInfo> list = packageManager.getInstalledApplications(PackageManager.GET_META_DATA);
List<String> values = new ArrayList<String>(0);
for(ApplicationInfo ap:list){
values.add(ap.packageName);
}
ListView lista = ListView.class.cast(findViewById(R.id.lista));
lista.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, values));