get Install App Info - Android App

Android examples for App:App Install

Description

get Install App Info

Demo Code


//package com.java2s;
import java.util.ArrayList;
import java.util.List;

import android.content.Context;

import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;

public class Main {

    public static List<PackageInfo> getInstallAppInfo(Context context) {
        PackageManager mgr = context.getPackageManager();
        List<PackageInfo> list = new ArrayList<PackageInfo>();
        for (PackageInfo packageInfo : mgr.getInstalledPackages(0)) {
            if (isUserInstallApp(packageInfo.applicationInfo)) {
                list.add(packageInfo);/*from   w w  w. j a  va  2s .  com*/
            }
        }
        return list;
    }

    public static boolean isUserInstallApp(ApplicationInfo info) {
        if ((info.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0) {
     
            return false;
        } else if ((info.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {

            return true;
        }
        return false;
    }
}

Related Tutorials