当前位置: 首页>>代码示例>>Java>>正文


Java ApplicationInfo.FLAG_INSTALLED属性代码示例

本文整理汇总了Java中android.content.pm.ApplicationInfo.FLAG_INSTALLED属性的典型用法代码示例。如果您正苦于以下问题:Java ApplicationInfo.FLAG_INSTALLED属性的具体用法?Java ApplicationInfo.FLAG_INSTALLED怎么用?Java ApplicationInfo.FLAG_INSTALLED使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.content.pm.ApplicationInfo的用法示例。


在下文中一共展示了ApplicationInfo.FLAG_INSTALLED属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getApplicationInfo

@Override
public ApplicationInfo getApplicationInfo(String packageName, int flags, UserHandle user) {
    final boolean isPrimaryUser = Process.myUserHandle().equals(user);
    if (!isPrimaryUser && (flags == 0)) {
        // We are looking for an installed app on a secondary profile. Prior to O, the only
        // entry point for work profiles is through the LauncherActivity.
        List<LauncherActivityInfo> activityList =
                mLauncherApps.getActivityList(packageName, user);
        return activityList.size() > 0 ? activityList.get(0).getApplicationInfo() : null;
    }
    try {
        ApplicationInfo info =
                mContext.getPackageManager().getApplicationInfo(packageName, flags);
        // There is no way to check if the app is installed for managed profile. But for
        // primary profile, we can still have this check.
        if (isPrimaryUser && ((info.flags & ApplicationInfo.FLAG_INSTALLED) == 0)
                || !info.enabled) {
            return null;
        }
        return info;
    } catch (PackageManager.NameNotFoundException e) {
        // Package not found
        return null;
    }
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:25,代码来源:LauncherAppsCompatVL.java

示例2: init

private void init() {
    String pkgName = pkgInfo.packageName;
    // Check if there is already a package on the device with this name
    // but it has been renamed to something else.
    final String[] oldName = pm.canonicalToCurrentPackageNames(new String[]{pkgName});
    if (oldName != null && oldName.length > 0 && oldName[0] != null) {
        pkgName = oldName[0];
        pkgInfo.packageName = pkgName;
        pkgInfo.applicationInfo.packageName = pkgName;
    }
    // Check if package is already installed
    try {
        // This is a little convoluted because we want to get all uninstalled
        // apps, but this may include apps with just data, and if it is just
        // data we still want to count it as "installed".
        //noinspection WrongConstant (lint is actually wrong here!)
        installedAppInfo = pm.getApplicationInfo(pkgName,
                PackageManager.GET_UNINSTALLED_PACKAGES);
        if ((installedAppInfo.flags & ApplicationInfo.FLAG_INSTALLED) == 0) {
            installedAppInfo = null;
        }
    } catch (PackageManager.NameNotFoundException e) {
        installedAppInfo = null;
    }
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:25,代码来源:AppDiff.java

示例3: isApplicationEnabled

/**
 * Checks if the application is available in this profile.
 *
 * @param packageName The package name
 * @return True if the application is available in this profile.
 */
private boolean isApplicationEnabled(String packageName) {
    Activity activity = getActivity();
    PackageManager packageManager = activity.getPackageManager();
    try {
        ApplicationInfo applicationInfo = packageManager.getApplicationInfo(
                packageName, PackageManager.GET_UNINSTALLED_PACKAGES);
        // Return false if the app is not installed in this profile
        if (0 == (applicationInfo.flags & ApplicationInfo.FLAG_INSTALLED)) {
            return false;
        }
        // Check if the app is not hidden in this profile
        DevicePolicyManager devicePolicyManager =
                (DevicePolicyManager) activity.getSystemService(Activity.DEVICE_POLICY_SERVICE);
        return !devicePolicyManager.isApplicationHidden(
                BasicDeviceAdminReceiver.getComponentName(activity), packageName);
    } catch (PackageManager.NameNotFoundException e) {
        return false;
    }
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:25,代码来源:BasicManagedProfileFragment.java

示例4: getApplicationInfo

@Override
public ApplicationInfo getApplicationInfo(String packageName, int flags, UserHandle user) {
    try {
        // TODO: Temporary workaround until the API signature is updated
        if (false) {
            throw new PackageManager.NameNotFoundException();
        }

        ApplicationInfo info = mLauncherApps.getApplicationInfo(packageName, flags, user);
        return (info.flags & ApplicationInfo.FLAG_INSTALLED) == 0 || !info.enabled
                ? null : info;
    } catch (PackageManager.NameNotFoundException e) {
        return null;
    }
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:15,代码来源:LauncherAppsCompatVO.java


注:本文中的android.content.pm.ApplicationInfo.FLAG_INSTALLED属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。