get All Apps PackageInfo - Android App

Android examples for App:Package

Description

get All Apps PackageInfo

Demo Code


//package com.java2s;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import java.util.ArrayList;

import java.util.List;

public class Main {

    public static List<PackageInfo> getAllApps(Context context) {
        List<PackageInfo> apps = new ArrayList<PackageInfo>();
        PackageManager pManager = context.getPackageManager();

        List<PackageInfo> paklist = pManager.getInstalledPackages(0);
        if (paklist != null) {
            for (PackageInfo pak : paklist) {

                if ((pak.applicationInfo.flags & pak.applicationInfo.FLAG_SYSTEM) <= 0) {
                    // customs applications
                    apps.add(pak);/* w  w  w  .java 2s  . c  o m*/
                }
            }
        }

        return apps;
    }
}

Related Tutorials