I'm making an Android launcher as an introduction to making Android apps for myself, and part of my design requires me to know how many apps are installed on a users device, and preferably count only the ones which are normal apps that can be launched. I wish to store this number of apps in a global, integer variable. With only this goal in mind, what is the simplest way of just retrieving this number as that variable?
You could use the
getInstalledApplications() method of
From the documentation:
Listof all application packages that are installed on the device. If flag
GET_UNINSTALLED_PACKAGEShas been set, a list of all applications including those deleted with
DONT_DELETE_DATA(partially installed apps with data directory) will be returned.
Something like this should work:
int numberOfInstalledApps = getPackageManager(0).getInstalledApplications().size();