Android | How to get list of all the apps installed on Android device

Author - Vivek Gautam

In one of the mobile app we were required to get the list of all the installed applications on user’s mobile. This was possible but due to security reasons first of all you need to prompt app user to allow access his/her device contents by showing a dialogue (EULA) when app runs for the first time otherwise google will reject your app. Then get all the content.

Here is sample code:

private void getInstalledApps(boolean getSysPackages)
{
//get user grant permission status from the preferences
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
boolean permissionGranted = sharedPreferences.getBoolean("PERMISSION_GRANTED", false);
//check if user has granted the permission to access device
if (permissionGranted)
{
String resource = "";
//Get all installed packages in a list
List packs = getPackageManager().getInstalledPackages(0);
//loop through the List
for (int i = 0; i < packs.size(); i++)
{
PackageInfo packageInfo = packs.get(i);
if ((!getSysPackages) && (packageInfo.versionName == null))
{
continue;
}
// Add package name in list
resource = resource.concat(packageInfo.packageName);
resource = resource.concat(",");
}
String packageString = res.substring(0, res.length() - 1);
Log.d("Package List: ",packageString);
}
}

Webner Solutions is a Software Development company focused on developing CRM apps (Salesforce, Zoho), LMS Apps (Moodle/Totara), Websites and Mobile apps. If you need any Android or iOS Mobile App developed please contact us at mobile@webners.com

Webner Solutions is a Software Development company focused on developing Insurance Agency Management Systems, Learning Management Systems and Salesforce apps. Contact us at dev@webners.com for your Insurance, eLearning and Salesforce applications.

Leave a Reply

Your email address will not be published. Required fields are marked *