Thursday , August 16 2018
Home / Android / How to Get List of Installed Apps in Android

How to Get List of Installed Apps in Android


installed2

Android PackageManager class is used to retrieve information on the application packages that are currently installed on the device. You can get an instance of PackageManager class by calling getPackageManager(). PackageManager provides methods for querying and manipulating installed packages and related permissions, etc. In this Android example, we we get list of installed apps in Android.

PackageManager packageManager = getPackageManager();
List<ApplicationInfo> list = packageManager.getInstalledApplications(PackageManager.GET_META_DATA)

packageManager.getInstalledApplications() return a List of all application packages that are installed on the device. If we set the flag GET_UNINSTALLED_PACKAGES has been set, a list of all applications including those deleted with DONT_DELETE_DATA (partially installed apps with data directory) will be returned.

1. Creating application layout in xml

activity_main.xml

As you can see in the attached screenshot, we will be creating a ListView to show all of the installed applications in android.

snippet_list_row.xml

This layout is being used by the ListView Adapter for representing application details. It shows application icon, application name and application package.

 

2. Writing Java class

AllAppsActivity.java
This is the main application class that is used to initialize and list the installed applications. As getting the list of application details from PackageManage is a long running task, we will do that in AsyncTask. Also, this class is using custom Adapter “ApplicationAdapter” for custom ListView.

ApplicationAdapter.java

 

About admin

Check Also

Android Activity Launch Modes

Launch mode is an instruction for Android OS which specifies how the activity should be ...

Leave a Reply