Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get list of installed android applications

Tags:

Hi I want to get a list of all of the installed applications on the users device I have been googling for the longest time but can't find what i want this link was the closest though and works fine except me being new don't understand how to use the method getPackages(); and create a list with it

http://www.androidsnippets.com/get-installed-applications-with-name-package-name-version-and-icon

Any help on how to create the actual list would be a major help i have all that code already in just can't get the list to actually show thanks for any help

like image 742
user577732 Avatar asked May 28 '11 23:05

user577732


People also ask

How can I get a list of all apps on my phone?

Find & open appsSwipe up from the bottom of your screen to the top. If you get All Apps , tap it. Tap the app that you want to open.

How do I show all apps on Android 11?

Swipe up and hold, and you'll get the multitasking pane with all your open apps. You can then swipe from side to side to access them.

How can I tell when an app was downloaded Android?

You can view the app download history in Google Play Store from the Installed or Library sections of the Store. The Installed section shows you all the apps currently installed on your Android device.


1 Answers

I was working on something like this recently. One thing I'll say up front is to be sure and perform this in a separate thread -- querying the application information is SLOW. The following will get you a list of ALL the installed applications. This will include a lot of system apps that you probably aren't interested in.

PackageManager pm = getPackageManager();
List<ApplicationInfo> apps = pm.getInstalledApplications(0);

To limit it to just the user-installed or updated system apps (e.g. Maps, GMail, etc), I used the following logic:

List<ApplicationInfo> installedApps = new ArrayList<ApplicationInfo>();

for(ApplicationInfo app : apps) {
    //checks for flags; if flagged, check if updated system app
    if((app.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0) {
        installedApps.add(app);
    //it's a system app, not interested
    } else if ((app.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
        //Discard this one
    //in this case, it should be a user-installed app
    } else {
        installedApps.add(app);
    }
}

EDIT: Also, to get the name and icon for the app (which is probably what takes the longest -- I haven't done any real deep inspection on it -- use this:

String label = (String)pm.getApplicationLabel(app);
Drawable icon = pm.getApplicationIcon(app);

installedApps should have a full list of the apps you need, now. Hope this helps, but you may have to modify the logic a bit depending on what apps you need to have returned. Again, it is SLOW, but it's just something you have to work around. You might want to build a data cache in a database if it's something you'll be accessing frequently.

like image 156
Kevin Coppock Avatar answered Oct 04 '22 19:10

Kevin Coppock