Example usage for android.content.pm PackageManager MATCH_DISABLED_COMPONENTS

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

Introduction

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

Prototype

int MATCH_DISABLED_COMPONENTS

To view the source code for android.content.pm PackageManager MATCH_DISABLED_COMPONENTS.

Click Source Link

Document

PackageInfo flag: include disabled components in the returned info.

Usage

From source file:org.deviceconnect.android.observer.fragment.WarningDialogFragment.java

/**
 * ????.//from  w  ww.j  a  va 2s  . c  om
 * 
 * @param packageName ???
 * @return ??
 */
private String getAppName(final String packageName) {
    PackageManager pm = getActivity().getPackageManager();
    final List<ApplicationInfo> appInfoList = pm.getInstalledApplications(
            PackageManager.MATCH_UNINSTALLED_PACKAGES | PackageManager.MATCH_DISABLED_COMPONENTS);

    for (ApplicationInfo ai : appInfoList) {
        String appName = ai.loadLabel(pm).toString();
        if (ai.packageName.equals(packageName)) {
            return appName;
        }
    }
    return "NoName";
}

From source file:org.deviceconnect.android.manager.setting.DevicePluginInfoFragment.java

/**
 * Tests whether packageName exists in application list.
 *
 * @param packageName package name// w  w w .  ja  v  a  2s .  com
 * @return true if packageName exists, false otherwise
 */
private boolean existApplicationFromPackageName(final String packageName) {
    if (packageName == null) {
        return false;
    }

    final PackageManager pm = getActivity().getPackageManager();
    final int flags = PackageManager.GET_UNINSTALLED_PACKAGES | PackageManager.MATCH_DISABLED_COMPONENTS;
    final List<ApplicationInfo> installedAppList = pm.getInstalledApplications(flags);
    for (ApplicationInfo app : installedAppList) {
        if (app.packageName.equals(packageName)) {
            return true;
        }
    }
    return false;
}