Android get device installed apps with icons

So we have an app which displays a list of the installed apps on the device from which the user can choose. Basically we display a gridview to the user which contains the app icon and title. To get the list of all apps on the device without the system apps is simple.

We have this util class which help us get the info for all packages we need:

import android.util.Log;

import java.util.ArrayList;
import java.util.List;

public class InstalledPackagesUtils {
    private static final String TAG =  InstalledPackagesUtils.class.getName();

    public static List installedPackages(PackageManager packageManager) {
        List installedPackages = new ArrayList();

        try {
            List packages = packageManager.getInstalledApplications(PackageManager.GET_META_DATA);

            for (ApplicationInfo applicationInfo : packages) {
                if (!isSystemPackage(applicationInfo)) {
                    if (!applicationInfo.packageName.equals(Constants.PACKAGE_NAME))
        } catch (Exception e) {
            Log.e(TAG, e.toString());

        return installedPackages;

    private static boolean isSystemPackage(ApplicationInfo applicationInfo) {
        return ((applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0);



And we have the following adapter to add apps to the gridview:


import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

!!!import .R;

import java.util.ArrayList;
import java.util.List;

public class UserAppsAdapter extends BaseAdapter {
    private static final String TAG = UserAppsAdapter.class.getName();

    private List appsList = new ArrayList<>();
    private Context ctx;
    private PackageManager packageManager;
    private LayoutInflater layoutInflater;

    public UserAppsAdapter(Context ctx, List appsList) {
        this.ctx = ctx;
        this.appsList = appsList;
        this.packageManager = ctx.getPackageManager();
        layoutInflater = (LayoutInflater) ctx

    public View getView(int position, View convertView, ViewGroup parent){
        View view=convertView;
        ViewHolder viewHolder;

        ApplicationInfo data = getItem(position);

        if(view == null) {
            view = layoutInflater.inflate(R.layout.layout_user_app_item, parent, false);
            viewHolder = new ViewHolder();
            viewHolder.icon = (ImageView) view.findViewById(;
   = (TextView) view.findViewById(;

        } else {
            viewHolder = (ViewHolder) view.getTag();


        return view;

    public int getCount() {
        return appsList.size();

    public ApplicationInfo getItem(int position) {
        return appsList.get(position);

    public long getItemId(int position) {
        return position;

    private class ViewHolder {
        ImageView icon;
        TextView name;

Basically the method which loads the icon is the loadIcon method of the ApplicationInfo class. This method accepts the package manager and returns a Drawable. So data.loadIcon(packageManager) is the tricky stuff.
Otherwise there is a great tutorial here: and the code of the android launcher:

You may also like...