Example usage for android.content.pm PackageManager getInstalledApplications

List of usage examples for android.content.pm PackageManager getInstalledApplications

Introduction

In this page you can find the example usage for android.content.pm PackageManager getInstalledApplications.

Prototype

public abstract List<ApplicationInfo> getInstalledApplications(@ApplicationInfoFlags int flags);

Source Link

Document

Return a List of all application packages that are installed for the current user.

Usage

From source file:Main.java

/**
 * Check for the Llama app.//  w w w.j a  va  2  s.  co m
 * @param c
 * @return
 */
public static boolean isLlamaInstalled(Context c) {
    boolean res = false;
    PackageManager pm = c.getPackageManager();
    for (ApplicationInfo ai : pm.getInstalledApplications(PackageManager.GET_META_DATA)) {
        if (ai.packageName.contains("com.kebab.Llama")) {
            res = true;
            break;
        }
    }
    return res;
}

From source file:Main.java

public static void initInstalledAppCache(final Context ctx, boolean forceRefresh) {
    if (sInstalledApps != null && !forceRefresh) {
        return;/*from w w w  .  j  a va  2 s .  co m*/
    }
    final PackageManager pm = ctx.getPackageManager();
    final List<ApplicationInfo> packages = pm.getInstalledApplications(PackageManager.GET_META_DATA);
    Map<String, Void> iapps = new HashMap<String, Void>(packages.size());
    for (final ApplicationInfo packageInfo : packages) {
        iapps.put(packageInfo.packageName, null);
    }
    sInstalledApps = iapps;
    sInstalledAppsLastUpdated = System.currentTimeMillis();
}

From source file:Main.java

public static List<ApplicationInfo> getInstalledApps() {
    if (mContext != null) {
        final PackageManager pm = mContext.getPackageManager();
        return pm.getInstalledApplications(PackageManager.GET_META_DATA);
    } else//www.  ja v a2s .  c  o  m
        return null;
}

From source file:Main.java

public static boolean isInstalled(Context context, String packageName) {
    final PackageManager pm = context.getPackageManager();
    List<ApplicationInfo> packages = pm.getInstalledApplications(PackageManager.GET_META_DATA);

    for (ApplicationInfo packageInfo : packages) {
        if (packageInfo.packageName.equals(packageName))
            return true;
    }/*from  w  ww. jav a 2 s.c o m*/

    return false;
}

From source file:Main.java

public static boolean isPackageInstalled(Context context, String packageName) {
    PackageManager pm = context.getPackageManager();
    List<ApplicationInfo> packages = pm.getInstalledApplications(0);
    for (ApplicationInfo packageInfo : packages) {
        if (packageInfo.packageName.equals(packageName)) {
            return true;
        }/*from w  ww  .  j a  v  a2 s. c  om*/
    }
    return false;
}

From source file:Main.java

public static ApplicationInfo getApplicationInfo(Context context, String processName) {
    if (processName == null) {
        return null;
    }/*from w w  w  .j  av  a 2  s.  c  o m*/

    PackageManager packageManager = context.getApplicationContext().getPackageManager();
    List<ApplicationInfo> appList = packageManager
            .getInstalledApplications(PackageManager.GET_UNINSTALLED_PACKAGES);
    for (ApplicationInfo appInfo : appList) {
        if (processName.equals(appInfo.processName)) {
            return appInfo;
        }
    }
    return null;
}

From source file:Main.java

public static List<ApplicationInfo> getInstalledApplications(PackageManager pm) {
    int retrieveFlags = PackageManager.GET_UNINSTALLED_PACKAGES | PackageManager.GET_DISABLED_COMPONENTS;
    List<ApplicationInfo> packages = pm.getInstalledApplications(retrieveFlags);
    return packages;
}

From source file:Main.java

/**
 * @param context//from ww  w  .j av  a2  s. c  o m
 * @param packageName
 * @return
 */
public static boolean isAvilible(Context context, String packageName) {
    final PackageManager packageManager = context.getPackageManager();
    List<PackageInfo> packageInfos = packageManager.getInstalledPackages(0);
    packageManager.getInstalledApplications(packageManager.GET_META_DATA);
    List<String> packageNames = new ArrayList<String>();
    if (packageInfos != null) {
        for (int i = 0; i < packageInfos.size(); i++) {
            String packName = packageInfos.get(i).packageName;
            packageNames.add(packName);
        }
    }
    return packageNames.contains(packageName);
}

From source file:com.mendhak.gpslogger.common.Systems.java

public static boolean isPackageInstalled(String targetPackage, Context context) {
    List<ApplicationInfo> packages;
    PackageManager pm;
    pm = context.getPackageManager();//from   w w  w  .  j av a 2  s  . c  o  m
    packages = pm.getInstalledApplications(0);
    for (ApplicationInfo packageInfo : packages) {
        if (packageInfo.packageName.equals(targetPackage))
            return true;
    }
    return false;
}

From source file:fr.inria.ucn.Helpers.java

/**
 * Check for the OpenVPN for Android app:
 * https://play.google.com/store/apps/details?id=de.blinkt.openvpn
 * @param c//from w w w  .  ja  va 2 s . c o  m
 * @return
 */
public static boolean isOpenVPNClientInstalled(Context c) {
    boolean res = false;
    PackageManager pm = c.getPackageManager();
    for (ApplicationInfo ai : pm.getInstalledApplications(PackageManager.GET_META_DATA)) {
        if (ai.packageName.contains("de.blinkt.openvpn")) {
            res = true;
            break;
        }
    }
    return res;
}